简体   繁体   English

单击按钮后,如何将textview1的值转换为textview2?

[英]how can i get the value of textview1 into textview2 after click the button?

i want the value of textview1 (which is asked by the user)is came into the textview2 after click the button. 我想在单击按钮后将textview1的值(由用户询问)输入到textview2中。 can you help me in this? 你能帮我吗?

Try this 尝试这个

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()); 
        });
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()); 
    });
public void onClick(View view) {    
    if(view == clickBtn) {
         text2.setText(text1.getText().toString());
    }    
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在此示例中,如何在Textview2顶部放置TextView1? - How in this example, can I have TextView1 on top of Textview2? 如何通过我的 textView1 从字符串资源中获取 textview2 getText 等于字符串名称 - How to textview2 getText from String resource by my textView1 is equal string name 当TextView1具有多行时,Textview2不是showm - Textview2 is not showm when TextView1 have more than one line 无法显示我的 Textview1 和 Textview2 之间的计算时间差? - Unable to show calculate Time difference between my Textview1 and Textview2? TextView1无法解析为一种类型 - TextView1 can't be resolved to a type 如何通过单击按钮从 RecyclerView 中的 TextView 和 Radio 按钮获取价值? - How to get value from TextView and Radio button in RecyclerView on click Button? Android:单击按钮时获取 Spinner 的 Textview 值 - Android: Get Textview value of Spinner on Button click 如何禁用可更改的TextView并单击它以重新启用按钮? - how can I disable the changable TextView and click on it reenable the button? 如何在小部件中的按钮单击上更新我的TextView? - How can I update my TextView on button click in widget? 单击按钮时,如何更新 Fragment 中的 TextView? - How can I update the TextView in Fragment when I click in a button?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM