I have a problem, a technical one. I have a list view, when I click an item I get content at that specific position and send it to next activity through 'putExtra'
On next activity what i am doing is
String item;
Bundle extras = getIntent().getExtras();
if (extras != null) {
item = extras.getString("item");
}
Now lets say here item = "Java";
Now what I want is termsArray = getResources().getStringArray(R.array.Java);
But i donot want R.array.Java, I want some thing like R.array.item
String Arrays in XML
<string-array name="Java">
<item>A</item>
<item>B</item>
<item>C</item>
</string-array>
<string-array name="C">
<item>A</item>
<item>B</item>
<item>C</item>
</string-array>
<string-array name="php">
<item>A</item>
<item>B</item>
<item>C</item>
</string-array>
I can do this task using IF-else but I have many String Arrays, so it is not possible to use IF-else
try as:
String item;
Bundle extras = getIntent().getExtras();
if (extras != null) {
item = extras.getString("item");
int arryid = this.getResources().getIdentifier(item, "array",
this.getPackageName());
termsArray = this.getResources().getStringArray(arryid);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With