Hello, guys!
In my ListView each item consists of ImageView and TextView. I want when I click on image - get itemid(and then show image in dialog).
How to catch click on ImageView and get Id of ListItem?
In my ListView each item consists of ImageView and TextView. I want when I click on image - get itemid(and then show image in dialog).
How to catch click on ImageView and get Id of ListItem?
Code:
ImageView image;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.content_friends);
contactsList=(ListView)findViewById(android.R.id.list);
contactsList.setOnItemClickListener(clickListener);
image = (ImageView)findViewById(R.id.image_a);
image.setOnClickListener(imListener);
}
OnItemClickListener clickListener = new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long itemId) {
Toast.makeText(getApplicationContext(), "listItem " + itemId, Toast.LENGTH_SHORT).show();
}
};
OnClickListener imListener = new OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(getApplicationContext(), "Image of listItem ", Toast.LENGTH_SHORT).show();
}
};