views:

91

answers:

2

Hi, my ANDROID app presents a listview, from a database cursor and XML, that needs to replace the values in a column with various words based on the integer value contained in the cursor. For example, if the value is -1, replace it with the word "Invalid", but if the value is >= 0 then just display the value.

I was under the impression this could magically be done via XML... TIA.

A: 

you can either use JS regular expressions (regexp) to replace them or use PHP Class

Tumharyyaaden
A: 

Since you don't state what language you are using, there might be some difference to the language of your choice:

yourValue = ( '-1' == yourValue ) ? 'Invalid' : yourValue;

This will replace the contents of yourValue with 'Invalid' if it is -1 or let it stay the same.

You need to modify this depending on how you access your variables (i.e. dollar signed prefixed: $yourValue).

If your language is type-aware, you might want to make sure that yourValue is already a string.

This is what you should do when printing the output or while reading the content of your file. XML itself does not change the values for you.

favo
Thanks favo. Makes sense that I need to do the formatting first. The data has a max of about 20 rows, so I'll read in the values, format them and place in an array, then stuff the array into the listview.
GaryAmundson