I'm trying to use string resources for my 2-line list view items rather than hard-coding them but I get this error. How can I fix that?
Before using string resources
public class ListData {
public static final String[][] items = {
{"America","America Description"},
{"Europe","Europe Description"},
};
}
After using string resources
public class ListData {
public static final String[][] items = {
{R.string.america,R.string.america_description},
{R.string.europe, R.string.europe_description},
};
}
Error
Incompatible types. Required: java.lang.String | Found: int
it is because
R.string.americais an integer which represent a string insidestrings.xml. So you should change the type forString[][]toint[][]. If you have to assign the value to aTextVIewandroid will take care of the look up instrings.xml.