Problems accessing my strings.xml items… i got numbers and not the string value

when from a java class i try to acces a item of my strings.xml file, i got numbers, like a mem position, and i dont get the string value of the item

for example:

if (parent.getItemAtPosition(pos).toString().equals(R.string.perdayspermission))

this code: R.string.perdayspermission haves to give me "Per Days", but it gives me a extrange number: 234552634

why?

Answers


Use getString() e.g.,

if (parent.getItemAtPosition(pos).toString().equals(getString(R.string.perdayspermission)))

Thats because R.string.perdayspermission is simply a numerical reference to where that string can be found. Try:

if (parent.getItemAtPosition(pos).toString().equals(getResources().getString(R.string.perdayspermission))

Update:

String item = parent.getItemAtPosition(pos).toString();
String test = getResources().getString(R.string.perdayspermission);
Log.i('test', 'item: '+item);
Log.i('test', 'test: '+test);
if(item.compareTo(test)==0)Log.i('test', 'strings match');

Need Your Help

Java Null Pointer Exception in Worker Class

java swing user-interface jpanel

Exception in thread "main" java.lang.NullPointerException

Access sessions in asp.net handler

asp.net vb.net session handler

I am trying to upload images using generic handler as shown below and I have a normal aspx page where I am showing all the uploaded images after uploading.Everything is working fine.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.