listview - ArrayAdapter initialization error (Android) -


i have written following code snippet in app:

public fragment getitem(int position) {      switch(position){         case 0:             lp_events_tab meventstab= new lp_events_tab();             mlist= (listview) findviewbyid(r.id.event_list);             string[] temp= {"1","2","3"};             arrayadapter<string> arrayadapter= new arrayadapter<string>(this, android.r.layout.simple_list_item_1, temp);             return meventstab;             /*other cases*/     }     return null; } 

for case 0, using array of strings named temp initialize arrayadapter. however, android studio redlines arrayadapter initialization arguments: (this,android.r.layout.simple_list_item_1, temp) , thus, cannot proceed. not see error these arguments android studio , hence, stuck.

replace following line of code inside fragment -

arrayadapter<string> arrayadapter= new arrayadapter<string>(getcontext(), android.r.layout.simple_list_item_1, temp); 

hope helps, let me know if need more help.


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -