Win a copy of OCP Java SE 8 Programmer II Exam Study Guide this week in the OCP forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

ListPreference problem  RSS feed

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello. I'm beginner in Java Android developing. I'm using Eclipse SDK 3.6.1 version. I have create a ListPreference in preference.xml:

I have call preference.java like that:

I cant get the value of ListPreference when I change the value. I do like that:

ListPreference arrays.xml:

If I change the value to "2" nothing happens.
 
Rancher
Posts: 42975
76
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


if (ListPreference == "2")


Strings are compared using the equals method, not using the == operator.
 
Evas Stank
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Ulf Dittmer. That resolve my problem.
 
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
also, that should be ListPreference.equals("2")
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!