android - How to create listview in fragment that is part of navigation drawer -


listed below fragment in navigation drawer attempting make listview in. there error on 2 lines, 1 starts setlistadapter , listview. says error there on those. how go fixing it.

error:(29, 9) error: cannot find symbol method setlistadapter(arrayadapter)

error:(30, 25) error: cannot find symbol method getlistview()

note: input files use or override deprecated api.

note: recompile -xlint:deprecation details.

error:execution failed task ':app:compiledebugjavawithjavac'.

compilation failed; see compiler error output details.

public class first extends fragment {   view myview;  @nullable  string[] courses = {"1", "2", "3"};  @override public void oncreate(bundle savedinstancestate){     super.oncreate(savedinstancestate); }  @override public void onactivitycreated(bundle savedinstancestate){     super.onactivitycreated(savedinstancestate);     setlistadapter(new arrayadapter<string>(getactivity(), android.r.layout.simple_list_item_1, courses));     listview list = getlistview();     list.settextfilterenabled(true);     list.setonitemclicklistener(new adapterview.onitemclicklistener() {          @override         public void onitemclick(adapterview<?> arg0, view view, int arg1, long arg2) {             switch (arg1) {                 case 0:                     intent myintent0 = new intent(view.getcontext(), test.class);                     startactivityforresult(myintent0, 0);                     break;                 case 1:                     intent myintent1 = new intent(view.getcontext(), test.class);                     startactivityforresult(myintent1, 0);                     break;                 case 2:                     intent myintent2 = new intent(view.getcontext(), test.class);                     startactivityforresult(myintent2, 0);                     break;             }         }     }); } public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) {     myview = inflater.inflate(r.layout.math, container, false);     return myview;  } }  <listview     android:id="@android:id/list"     android:layout_width="match_parent"     android:layout_height="wrap_content"/> 

both setlistadapter , getlistview methods in listfragment class, extending fragment.

you should read on layouts , creating navigation drawer. in xml layout you'll want wrap listview inside nav-drawer.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -