Xamarin android--Data binding to Controls (iii)

Source: Internet
Author: User

If there is only one ListView view in the current activity, you can quickly implement a list with listactivity, that is, the active activity inherits Listactivity. In the OnCreate method, you can create a list of users by simply two lines of code.

string[] items =New string[]{                 "Listing 1","Listing 2","Listing 3","Listing 4","Listing 5","Listing 6","Listing 7","Listing 8"            };  This. ListAdapter =Newarrayadapter<string> ( This, Android.resource.layout.simplelistitem1,items);

With Listactivity, you can create a simple list without calling the Setcontentview method. For more complex displays, you can customize the display layout and simpleadapter implementation. The layout of each subkey of the list is passed Android.Resource.Layout.SimpleListItem1. The system provides several simple layout styles.

Detailed introduction to each layout reference http://developer.android.com/reference/android/R.layout.html#simple_list_item_activated_1

To add a ListView click event, simply rewrite the Onlistitemclick method to

protected Override void int Long ID)        {            Toast.maketext (This,"click", Toastlength.long). Show ();        }

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.