Reputation: 115
So I try to show the String variable in GUI that I inherit from a parent activity.
This is my xml code
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:inputType="text"
android:textStyle="italic"
android:id="@+id/Edit_Title_Update"
android:text="@string/updating_title"/>
This is my String definition
<string name="updating_title"> %s </string>
This is how I try to put date into the String
String updating_title = getString(R.string.updating_title, show_title);
Log.e("MyTag","Here2 "+updating_title);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_update__diary);
In the console I can see the variable is correct
01-05 10:19:29.767 2849-2849/com.example.wenhaowu.diaryproject E/MyTag﹕ Here2 Happy
But In the emulator the String remains the same
What is the problem and how can I fix it? Thank you.
Upvotes: 0
Views: 11108
Reputation: 28823
Changing String updating_title
won't change the actual String resource updating_title
in strings.xml.
You would need to set text in EditText in your activity after setContentView
Like:
EditText e = (EditText) findViewById (R.id.my_edt_text);
e.setText(updating_title);
Hope this helps.
Upvotes: 2
Reputation: 157487
nothing is wrong, you just need to find your EditText
and call setText
on the instance, to update its content with the new value. After setContetView
EditText t = (EditText) findViewById(R.id.Edit_Title_Update);
t.setText(updating_title);
Upvotes: 1