I have created a List of Contacts that's working but when I click on any contact I only get contact Number of 1st Item on the android screen from the ListView.
I want to get Phone Number of clicked contact of that position. I have searched on web everywhere but didn't get any solution, i am trying to solve this issue for last 13 days but still i am unable to solve this, If anyone can resolve this issue please answer. Thanks for your help brother/sister!
li.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
TextView txtNummber = li.findViewById(android.R.id.text2)
}
});
In your onItemClick()
, you're using li.findViewById()
.
But, onItemClick()
returns View
as an argument of the clicked item, which is also mentioned in the official documentation.
Hence, try updating it as
TextView txtNummber = view.findViewById(android.R.id.text2)
.
Check if it works.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With