Android, use ListView in fragment, do not use listfragment

Source: Internet
Author: User

 Public classLeftfragment extends fragment{Privatelistview listview; @Override PublicView Oncreateview (Layoutinflater inflater, ViewGroup container,bundle savedinstancestate) {View View= Inflater.inflate (R.layout.lesson_table_left,NULL); ListView=(ListView) View.findviewbyid (R.id.listview); init ();returnview;} @Override Public voidonactivitycreated (Bundle savedinstancestate) {//TODO auto-generated Method Stubsuper.onactivitycreated (savedinstancestate);}Private voidinit () {List<String> items =NewArraylist<string>(); for(inti =0; I <2; i++) {if(i = =0) {Items.Add ("Timetable");}Else{Items.Add ("Exams");}} Arrayadapter<String> adapter =NewArrayadapter<string> ( This. Getactivity (), Android. R.layout.simple_list_item_1, items); Listview.setadapter (adapter);} The use of ListView in fragment does not require customization, so you can, if you want to customize the suggestion you still use listfragment, in fragment I studied for a long time did not study. 

Android, use ListView in fragment, do not use listfragment

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.