【发布时间】:2011-12-18 12:21:06
【问题描述】:
我目前正在使用具有以下行为的应用程序: 我正在使用 2 Edittext,我在其中输入了一些值,当我按下按钮时 它将转到下一页或活动,但是当我返回活动时,问题就在这里,我在edittext中找不到值,请帮助我.. 请告诉我代码... 在此先感谢....
这是我的代码....
public class TestsampleActivity extends Activity
{
Button b1,b2;
TextView t1;
EditText e1;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
b1= (Button)findViewById(R.id.btn1);
b2= (Button)findViewById(R.id.btn2);
t1=(TextView)findViewById(R.id.tv1);
e1=(EditText)findViewById(R.id.et1);
b1.setOnClickListener(new Button.OnClickListener()
{
public void onClick (View v){ add(); }
});
b2.setOnClickListener(new Button.OnClickListener()
{
public void onClick (View v){ del(); }
});
}
public void add()
{
String s1= e1.getText().toString();
Intent intent=new Intent(this,next.class);
intent.putExtra("name",s1);
startActivity(intent);
/* String s1= e1.getText().toString();
//t1.append(s1);
t1.setText(s1);
*/
}
public void del()
{
e1.setText("");
t1.setText("");
}
}
【问题讨论】:
标签: android