我有这张桌子:
public class MainActivity extends AppCompatActivity {
Button button;
TextView textView;
ArrayList<Integer> list = new ArrayList<Integer>();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
button = (Button)findViewById(R.id.button);
textView = (TextView)findViewById(R.id.textView);
list.add(0);
list.add(1);
list.add(2);
list.add(3);
}
public void button(View view) {
Random rand = new Random();
int randomElement = list.get(rand.nextInt(list.size()));
if (list.isEmpty()) {
textView.setText("Empty");
} else if (randomElement == 0) {
textView.setText("Red");
list.remove(randomElement);
} else if (randomElement == 1) {
textView.setText("Blue");
list.remove(randomElement);
} else if (randomElement == 2) {
textView.setText("Yellow");
list.remove(randomElement);
} else if (randomElement == 3) {
textView.setText("Green");
list.remove(randomElement);
}
}
}
我从另一个数据库复制它,我希望它将每一行增加1,目前它将每个新行增加1但是当达到100时它变为1000,当达到1099时它变为2000而不是1100,1101所以上 .... 如何解决它连续增加1?