I am passing a value from one activity to another through putExtra() and getExtra() and getting value like:
Passing from Activity 1:
intent = new Intent(this, blankScrollActivity.class);
intent.putExtra("alphabets", "a");
Recieving at Activity 2: blankScrollActivity.class
Bundle extras = getIntent().getExtras();
String varName = extras.getString("alphabets");
TextView textView = (TextView) findViewByid(R.id.blankTextView);
String Resource MyString.xml:
<string name="a">My Example 1</string>
<string name="b">My Example 2</string>
I want to get the value of string dynamically to assign textView.
Bundle extras = getIntent().getExtras();
String varName = extras.getString("alphabets");
int resId = getResources().getIdentifier(varName , "string", getPackageName());
String data = getResources().getString(resId);
This way, you will get the String resource that you want based on the String value sent from the first Activity.
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