Android ListView Get the value in the option _android

Source: Internet
Author: User

How do we get the value of the ListView check in Android?

For example, if we've got the names and phone numbers of the contacts saved in the phone and shown them in an Android ListView, now the function is to dial directly when you click on the selection, how do you get the number in the Android ListView?

To display the contact name and phone number, you must now have two controls in the ListView item, if it is TextView bar, then you should first add a onitemclicklistener to ListView To monitor the item you clicked, there is a Onitemclick method inside the Onitemclicklistener, which has a view parameter, so you can pass View.findviewbyid ("Your Control name") to find it.

code example:

ListView ListView = (ListView) Findviewbyid (R.id.listview); 
Onitemclicklistener lvitemclicklistener=new Onitemclicklistener () {public
	void Onitemclick (adapterview parent, View view, 
 	int position, long ID) {
 final TextView content= (TextView) View.findviewbyid (r.id.phonenumber);) 
	} 
}

Content is the value you want.

The above is an example of how Android gets the value of the ListView option, and a friend in need can refer to it.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.