Search code examples
javaandroidcharsequence

Problem with strings.xml... can't pass R.string.foo as a CharSequence


I'm running a TabActivity. In the following line:

spec = tabHost.newTabSpec("alltime").setIndicator(R.string.plots_allTime)
       .setContent(intent);

I get an error because setIndicator() expects a CharSequence. I'm not really sure how to fix this, because I should be able to pass a string into that parameter. I think the issue lies in the fact that the generated R.java initializes everything in the strings.xml file as public static final int. The setIndicator() method doesn't seem to like that too much. Is there any way around this?


Solution

  • spec = tabHost.newTabSpec("alltime").setIndicator(getString(R.string.plots_allTime))
    .setContent(intent);