I want to count the number of clicks of particular item in list view. Suppose there are 3 items in list view and I click 1st item for 1st time, it should display toast message t
Simply you can use Map<String, Integer>
here to get the count for your ListView item. Just keep the default value as 0 in the Map and add 1 always inside the onItemClick()
of ListView.
Pseudo Code,
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int position,
long arg3) {
int count = 0;
try {
count = map.get(your_listview_value);
} catch (Exception e) {
e.printStackTrace();
}
map.put(your_listview_value, (count + 1));
Toast.makeText(getBaseContext(),
String.valueOf(count), Toast.LENGTH_LONG).show();
}