Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to address an image which is in system resource in android

I am writing a media player in which I am using Image buttons and Images are from system resource. Now in java file, how should it be addressed? here is the code:

case R.id.ib2:
    if (isPlaying) {
         pause();
         //the red line is under R.drawable.ic_media_pause
         playPause.setImageResource(R.drawable.ic_media_pause);
like image 362
Civiato Avatar asked Sep 28 '22 01:09

Civiato


1 Answers

You need to use android's resource file, like so:

playPause.setImageResource(android.R.drawable.ic_media_pause);

Or You can add it to the imports if you aren't using any of your own resources:

import android.R;
like image 176
Chris Stillwell Avatar answered Oct 13 '22 13:10

Chris Stillwell