我搜索了stackoverflow的答案买不能找到一个所以我发帖子问。帮助之手非常感谢。
我正在创建一个测验应用程序。该布局包含六个textview框和12个带字母的按钮。当用户点击按钮textview时,每个字母都会填充,并根据位置递增textview,以便所有六个textview框都被填充。文本填充textview后,按钮也会消失。我成功实现了这些步骤,但我的问题是如何将填充的textview文本设置为空,以便相应的按钮重新出现?更清楚我将onClickListener添加到textview但是textview中的填充文本不会减少。希望你能理解这个问题。我还在学习,正在从头开发应用程序。
switch(v.getId())
{
case R.id.button1:
{
b1=(Button) findViewById(R.id.button1);
String name1=b1.getText().toString();
tv.setText(name1);
position++;
b1.setVisibility(View.INVISIBLE);
}
break;
case R.id.button2:
b2=(Button) findViewById(R.id.button2);
String name2=b2.getText().toString();
//blankbut.setText(name2);
tv.setText(name2);
position++;
b2.setVisibility(View.INVISIBLE);
break;
case R.id.button3:
b3=(Button) findViewById(R.id.button3);
String name3=b3.getText().toString();
tv.setText(name3);
//blankbut.setText(name3);
position++;
b3.setVisibility(View.INVISIBLE);
break;
case R.id.button4:
b4=(Button) findViewById(R.id.button4);
String name4=b4.getText().toString();
tv.setText(name4);
//blankbut.setText(name4);
position++;
b4.setVisibility(View.INVISIBLE);
break;
case R.id.button5:
b5=(Button) findViewById(R.id.button5);
String name5=b5.getText().toString();
tv.setText(name5);
//blankbut.setText(name5);
position++;
b5.setVisibility(View.INVISIBLE);
break;
case R.id.button6:
b6=(Button) findViewById(R.id.button6);
String name6=b6.getText().toString();
tv.setText(name6);
//blankbut.setText(name6);
position++;
b6.setVisibility(View.INVISIBLE);
break;
case R.id.button7:
b7=(Button) findViewById(R.id.button7);
String name7=b7.getText().toString();
tv.setText(name7);
// blankbut.setText(name7);
position++;
b7.setVisibility(View.INVISIBLE);
break;
case R.id.button8:
b6=(Button) findViewById(R.id.button8);
String name8=b8.getText().toString();
tv.setText(name8);
//blankbut.setText(name8);
position++;
b8.setVisibility(View.INVISIBLE);
break;
case R.id.button9:
b9=(Button) findViewById(R.id.button9);
String name9=b9.getText().toString();
tv.setText(name9);
//blankbut.setText(name9);
position++;
b9.setVisibility(View.INVISIBLE);
break;
case R.id.button10:
b10=(Button) findViewById(R.id.button10);
String name10=b10.getText().toString();
tv.setText(name10);
//blankbut.setText(name10);
position++;
b10.setVisibility(View.INVISIBLE);
break;
case R.id.button11:
b11=(Button) findViewById(R.id.button11);
String name11=b11.getText().toString();
tv.setText(name11);
//blankbut.setText(name11);
position++;
b11.setVisibility(View.INVISIBLE);
break;
case R.id.button12:
b12=(Button) findViewById(R.id.button12);
String name12=b12.getText().toString();
tv.setText(name12);
//blankbut.setText(name12);
position++;
b12.setVisibility(View.INVISIBLE);
break;
}