是否有任何API可以跟踪Android中GridView的索引?
答案 0 :(得分:6)
您是否为GridView设置了OnItemClickListener
?
gridView.setOnItemClickListener(
new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Toast.makeText(
getApplicationContext(),
String.format("Clicked on position #%s (id = %s)", position, id),
Toast.LENGTH_SHORT
).show();
}
}
);