Reputation: 65
I have the following code:
package com.sample.app;
import android.content.res.Resources;
import java.util.ArrayList;
public class Content {
public static ArrayList<String> Names;
public static ArrayList<String> NamesSub;
public static ArrayList<String> Images;
public static ArrayList<String> Wallpaper;
public static ArrayList<String> Audio;
public static ArrayList<String> BIG_Images;
public static ArrayList<String> Sub_heading;
public static ArrayList<String> Description;
Content(){
this.Names = new ArrayList<String>();
this.NamesSub = new ArrayList<String>();
this.Sub_heading = new ArrayList<String>();
this.Images = new ArrayList<String>();
this.Wallpaper = new ArrayList<String>();
this.BIG_Images = new ArrayList<String>();
this.Audio = new ArrayList<String>();
this.Description = new ArrayList<String>();
this.Description.add(0, "Long description");
this.Description.add(1, "");
this.Description.add(2, "");
}
}
And have a too long description for ArrayList
. when I paste the description it gave me
error: constant string too long
error. After that i tried setting values from strings.xml
. I am using this code for getting values:
this.Description.add(0,String.valueOf(R.string.descvalue));
But when I run the app it prints numbers like this 2131689519
not my values.
After that i tried string-array
<string-array name="descvalue">
<item>too long value</item>
</string-array>
And in the java file, I tried getting values with this code:
this.Description.add(0, getResources().getStringArray(R.array.descvalue)[0]);
But when I run the app it's crashing.
So what should I do in this case? Thanks.
Upvotes: 0
Views: 144
Reputation: 2419
Replace
this.Description.add(0,String.valueOf(R.string.descvalue));
With
this.Description.add(0,getString(R.string.descvalue));
but getString()
needs a context
.
Upvotes: 1
Reputation: 38
"error: constant string too long"
for this, you can go with Text class
Text text = new Text("foo");
String s = text.getText();
text.setText(s);
Upvotes: 1