-1

I have an ArrayList adapter wich used to load my listView. My problem is that I want to change a pictures on the items in the list; Until now I used a simple String array and didnt have any problem, but I had to change it to ArrayList wich loaded by an ORMlite selection and now my adapter doesent change the pictures...

I toast the text of the item wich is like ..."Asd"... and in the adapter I use this:

if(textView.getText()=="Asd"){imageView.setImageResource(R.drawable.ic_asd);}

I also tried this:

if(values.get(position).getName()=="Asd")
    {
        imageView.setImageResource(R.drawable.ic_asd);
    }

What is the problem? :S

Csabi Vidó
  • 146
  • 1
  • 12

3 Answers3

2

Well, it's hard to say exactly what the issue is, but the main thing that's sticking out is that you're checking String equality wrong.

To check string equality, you should use Object.equals(Object obj); For example, textView.getText()=="Asd" should be textView.getText().toString().equals("Asd");

Submersed
  • 8,810
  • 2
  • 30
  • 38
1

Use

if(textView.getText().toString().equals("Asd"))

I'm sure this is the problem ;)

Ajay Takur
  • 6,079
  • 5
  • 39
  • 55
Vladislav Kan
  • 354
  • 1
  • 12
1

yes your problem is that you should use textview.getText().equals("Asd")

Ufuk Garip
  • 43
  • 1
  • 7