在android中怎样获取Button上的值放到Textview中

2025-06-21 19:43:59
推荐回答(3个)
回答1:

具体操作如下:

Button bt =(Button)findViewById(R.id.button1);

TextView tx=(TextView)findViewById(R.id.textView1);

tx.setText(bt.getText());

getText()就是获取按钮上的文字,在TextView中显示出来

回答2:

具体操作如下:
Button bt =(Button)findViewById(R.id.button1);
TextView tx=(TextView)findViewById(R.id.textView1);
tx.setText(bt.getText());
getText()就是获取按钮上的文字,在TextView中显示出来

回答3:

Button bt =(Button)findViewById(R.id.button1);
TextView tx=(TextView)findViewById(R.id.textView1);
tx.setText(bt.getText());
getText()就是获取按钮上的文字,在TextView中显示出来