80,351
社区成员
发帖
与我相关
我的任务
分享
Button button1=(Button)findViewById(R.id.button1);
Button button2=(Button)findViewById(R.id.button2);
button1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent =new Intent();
intent.putExtra("button", "button1");
intent.setClass(Test01Activity.this, TextActivity.class);
startActivity(intent);
textActivity代码:
[code=Java]
TextView textView1 =(TextView)findViewById(R.id.textView1);
TextView textView2 =(TextView)findViewById(R.id.textView2);
Intent intent =this.getIntent();
String msg=intent.getStringExtra("button");//得到意图值
if (msg.equals("button1")) {
textView2.setVisibility(View.GONE);//隐藏textView2控件
}else if(msg.equals("button2"))
{
textView1.setVisibility(View.GONE);//隐藏textView1控件
}