请参阅this的问题。我不认为这是可能的,你可能想要做的就是存储用户在SharedPreferences中输入的内容。
编辑: 采取的字符串变量,并在屏幕上显示出来,你会想要一个TextView添加到您的布局:
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/textview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text=""/>
然后在代码中你将一个侦听器添加到您的按钮来监听单击事件,并在你的类TextView的一个参考:
字段类:
TextView tv;
Button myButton;
EditText et;
onCreate():
tv = (TextView)findViewById(R.id.textview);
myButton = (Button)findViewById(R.id.button);
et = (EditText)findViewById(R.id.edittext);
//Now set the onclick listener:
myButton.setOnClickListener(new Button.OnClickListener() {
public void onClick(args....)
{
String txt = et.getText().toString();
tv.setText(txt);
}
});
还检查了this教程。
嗯,我明白了。我想我应该改写我的问题。只需将字符串变量显示在屏幕上,最简单的方法是什么? –
啊,就在那里。我想踢自己想念那么小的事情。我使用了setText(变量)的所有代码。谢谢! –