Adapter 1, Arrayadapter 2.SimpleAdapter

Source: Internet
Author: User

Arrayadapter (Array adapter): Used to bind single-frame data. Data source: Can be a collection or an array

public class Mainactivity extends appcompatactivity  {    private ListView lv;    Private arrayadapter<string> Arr_adapter;    @Override    protected void onCreate (Bundle savedinstancestate) {        super.oncreate (savedinstancestate);        Setcontentview (r.layout.activity_main);        LV = (ListView) Findviewbyid (R.id.listview);        String[] Array_data = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday"};        1. Create a new adapter        //arraydapter (context, each load list item corresponding to the layout file, data source,)        //  2. Adapter Load Data source        Arr_adapter = new Arrayadapter<string> (this,android.  R.layout.simple_list_item_1,array_data); Android comes with a layout file to be aware of first Android. R.        3. View ListView Load Adapter        lv.setadapter (arr_adapter);}    }

  

Adapter 1, Arrayadapter 2.SimpleAdapter

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.