public class TestAndriodActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//用EditText前,请先:import android.widget.EditText;
//获取文本框1的文本
String str1="";
EditText editText1 =(EditText)findViewById(R.id.editText1);
str1=editText1.getText().toString();
//将文本框1的文本赋给文本框2
EditText editText2 =(EditText)findViewById(R.id.editText2);
editText2.setText(str1.toCharArray(), 0, str1.length());
}
}
Android之获取、设置EditText的文本...
最新推荐文章于 2024-06-28 21:19:55 发布