0

I want a particular image to be displayed for a corresponding text So I tried like below in my increase()

    TextView hedng = (TextView) findViewById(R.id.singleitemheading);
    if(hedng.getText() == "HEADING OF THE TOPIC"){
        ImageView lvlm = (ImageView) findViewById(R.id.levelimg);
        lvlm.setImageResource(R.drawable.ic_launcher);
        }

But the image is not being displayed

user5524159
  • 553
  • 5
  • 16

2 Answers2

1
TextView hedng = (TextView) findViewById(R.id.singleitemheading);
if(hedng.getText().toString().equalsIgnoreCase("HEADING OF THE TOPIC")){
    ImageView lvlm = (ImageView) findViewById(R.id.levelimg);
    lvlm.setImageResource(R.drawable.ic_launcher);
    }
Kishan Soni
  • 816
  • 1
  • 6
  • 19
0

If I understood what you mean by "image not getting displayed". You probably want to use setImageDrawable instead.

Resources resources = getResources();
lvlm.setImageDrawable(resources.getDrawable(R.drawable.ic_launcher));
Eduardo
  • 4,282
  • 2
  • 49
  • 63