我有一个包含多个值的数组列表。我在数组列表上执行随机函数,我想存储每个随机值,例如,只需点击列表视图中的按钮即可。我怎么能这样做?
Int rand;
String[] listv={"one","two","three","four","five"}
rand=(int)(Math.random()*5);
ArrayList<String> planetList = new ArrayList<String>(); planetList.addAll(Arrays.asList(listv[rand]));
adapter = new ArrayAdapter<String>(this, R.layout.txtlay,planetList);
listView = (ListView) findViewById(R.id.listView);
listView.setAdapter(adapter);
答案 0 :(得分:0)
使用两个不同的列表:第一个包含所有可能的值,第二个包含列表视图的所有随机添加的值。