我认为我可以使用position int,但是当我单击列表视图中的项目时,什么也没有发生。请帮帮我!
ListView d = (ListView) findViewById(R.id.apo);
ArrayAdapter adapt = ArrayAdapter.createFromResource(this,
R.array.algebra, android.R.layout.simple_list_item_1);
d.setAdapter(adapt);
d.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
if (position == '0') {
Intent intent = new Intent(Algebra.this, Alqv.class);
startActivity(intent);
}
if (position == '2') {
Intent intent1 = new Intent(Algebra.this, qfs.class);
startActivity(intent1);
}
});
}发布于 2010-06-03 09:49:46
这里的位置是一个整数,所以应该与整数进行比较,而不是与字符('0','1'...)进行比较。
if (position == 0) {
Intent intent = new Intent(Algebra.this, Alqv.class);
startActivity(intent);
}
if (position == 2) {
Intent intent1 = new Intent(Algebra.this, qfs.class);
startActivity(intent1);
}发布于 2012-11-13 12:36:04
这里的位置是一个整数。无法与字符(‘0’,'0')进行比较。
https://stackoverflow.com/questions/2962846
复制相似问题