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.
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.
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);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.