java - android context in static method is undefined -


i tried put context in static method below :

public class menu_sppaj extends activity { public static void onrefreshlist() {      model.requery();      list_terbaru.setadapter(new adapter_spaj_terbaru(menu_sppaj.this,model)); } } 

but menu_sppaj.this undefined in static method, there anyway how call context in static method?

use code context in static method.  public class menu_sppaj extends activity { public static context context;     @override     public void oncreate(bundle savedinstancestate) {        //todo write oncreate code         context = this;     } public static void onrefreshlist() {      model.requery();      list_terbaru.setadapter(new adapter_spaj_terbaru(((activity) context),model)); } } 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -