class clicker implements Button.OnClickListener
{
public void onClick(View v)
{
if(v==button1)
{
text1.setText(myChoice);
Toast.makeText(getBaseContext(),
"~~~~Successfully submitted~~~",
Toast.LENGTH_LONG).show();
}
if(v==button2)
{
/*Intent viewDataIntent = new Intent(SurveyActivity.this, Survey2.class);
String myData = "You should see this";
viewDataIntent.putExtra("valueOne", myData);
startActivity(viewDataIntent);
*/
text2.setText(text1.getText());
Toast.makeText(getBaseContext(),
text1.getText(),
Toast.LENGTH_LONG).show();
}
}
}
在上面的程序中,有两个editText框text1和text2;我试图将text1的内容复制到text2。我试过text2.setText(text1.getText());
但是没有用。有什么想法吗?
答案 0 :(得分:1)
尝试
text2.setText(text1.getText().toString());
答案 1 :(得分:1)
if(text1.length()!=0){
text2.setText(text1.getText());
}