I have a listview with some items.I want to know the list item click.for example if i click on listview item 1st time a toast message will be a appeared.again same item clic
You can add an additional ArrayList, that will contain a counter for each of your list view items.
Let say that you have:
ArrayList<String> listViewData = getSomeData();
ArrayList<Integer> dataClickCount = new ArrayList<>();
for(String item : listViewData)
{
dataClickCount.add(0);
}
And later in your listener:
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
if(dataClickCount.get(posion)%2==0){
Toast.makeText(getApplicationContext(), "Clicked on Row1nd, odd click: " + country.getName(), Toast.LENGTH_LONG).show();
dataClickCount.set(posion,1);
}
else{
Toast.makeText(getApplicationContext(), "Clicked on Row2st, even click: " + country.getName(), Toast.LENGTH_LONG).show();
dataClickCount.set(posion,0);
}
}});