android - The constructor ArrayAdapter<String>(LayoutNext, int, String[]) is undefined -


i try implement items spinner android.support.v4.app.fragment class. compiler error

the constructor arrayadapter(layoutnext, int, string[]) undefined

how can fix this? here code:

    public class layoutnext extends fragment                              implements onclicklistener,onitemselectedlistener{      timepicker timepicker;     private spinner spinner_next;     public arrayadapter<string> adapter;      public static fragment newinstance(context context) {         layoutnext f = new layoutnext();              return f;     }      public view oncreateview(layoutinflater inflater, viewgroup container,bundle savedinstancestate) {         viewgroup root = (viewgroup) inflater.inflate(r.layout.layout_next, null);            timepicker = (timepicker) root.findviewbyid(r.id.timepicker1);         timepicker.setis24hourview(true);         timepicker.setcurrenthour(0);         timepicker.setcurrentminute(0);          string[] items_next = { "next", "from to"};         spinner_next = (spinner) root.findviewbyid(r.id.sp_next);         spinner_next.setonitemselectedlistener(this);   // here error         arrayadapter<string> adapter = new arrayadapter<string>(                 this,                 android.r.layout.simple_spinner_item,                  items_next);         adapter.setdropdownviewresource(android.r.layout.simple_spinner_dropdown_item);         spinner_next.setadapter(adapter);          return root;     } 

unlike activities, fragments not subclasses of context cannot use this context required. use getactivity() instead.

arrayadapter<string> adapter = new arrayadapter<string>(         getactivity(),         android.r.layout.simple_spinner_item,          items_next); 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -