单击按钮后,如何将textview1的值输入textview2?

时间:2011-03-14 10:14:58

标签: android

我希望textview1(由用户询问)的值在点击按钮后进入textview2。 你可以帮帮我吗?

3 个答案:

答案 0 :(得分:2)

试试这个

final TextView textView1 = (TextView)findViewById(R.id.a);
        final TextView textView2 = (TextView)findViewById(R.id.b);
        Button button = (Button)findViewById(R.id.c);

        button.setOnClickListener(new View.OnClickListener(){
            textView2.setText(textView1.getText()); 
        });

答案 1 :(得分:1)

TextView textView1 = (TextView) findViewById(R.id.yourTextView1);
    TextView textView2 = (TextView) findViewById(R.id.yourTextView2);
    Button button = (Button) findViewById(R.id.yourButton);
button.setOnClickListener(new View.OnClickListener(){
        textView2.setText(textView1.getText()); 
    });

答案 2 :(得分:0)

public void onClick(View view) {    
    if(view == clickBtn) {
         text2.setText(text1.getText().toString());
    }    
}