在您的处理程序方法中:
if(playerList.size() < 10) { // playerList.add} else { // do nothing}
编辑 :您的错误在这里:
if(playerList.size() < 10) { Button confirm = (Button) findViewById(R.id.add); /confirm/i.setonClickListener(new onClickListener() { public void onClick(View v) { EditText playername = (EditText) findViewById(R.id.userinput); playerList.add(playername.getText().toString()); adapter.notifyDataSetChanged(); playername.setText(""); }});} else { // do nothing}
您应在而
onClickListener不是外部检查尺寸:
Button confirm = (Button) findViewById(R.id.add); /confirm/i.setonClickListener(new onClickListener() { public void onClick(View v) { EditText playername = (EditText) findViewById(R.id.userinput); if(playerList.size() < 10) { playerList.add(playername.getText().toString()); adapter.notifyDataSetChanged(); playername.setText(""); } else { // do nothing } } });
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)