我目前正在制作一个具有edittext和2个按钮的应用程序,每次我在edittext中写一些东西然后按button1,都会添加一个新的textview。这是代码:
public void novVnos (View v){
EditText eText = (EditText) findViewById(R.id.editText1);
LinearLayout mLayout = (LinearLayout) findViewById(R.id.linearLayout);
mLayout.addView(createNewTextView(eText.getText().toString()));
}
private TextView createNewTextView (String text){
final LayoutParams lparams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
final TextView newTextView = new TextView(this);
newTextView.setLayoutParams(lparams);
newTextView.setText(text);
return newTextView;
}
基本上我正在做的是添加新的“玩家”,一旦我添加了他们所有我想按下按钮2。Button2 打开一个新活动,新活动应该读取我在上一个活动中添加的所有文本视图。