Cannot make a static reference to the non-static method setContentView(int) from the type Activity

public static void setAdapter(MySimpleAdapter adapter) { // TODO Auto-generated method stub setContentView(adapter.getListId()); //错误处setContentView for(int i=0;i<adapter.getKey().length;i++){ TextView text=(TextView) findViewById(adapter.getchildId()[i]);//错误处findViewbyId text.setText((CharSequence) adapter.getList().get(0).get(adapter.getKey()[i])); } }另外我写的 MySimpleAdapter类public class MySimpleAdapter { private Context context; private List<Map<String,Object>> list; private int listId; private String[] key; private int[] childId; public List<Map<String,Object>> getList(){ return list; } public int getListId(){ return listId; } public String[] getKey(){ return key; } public int[] getchildId(){ return childId; } public MySimpleAdapter(Context context,List<Map<String,Object>> list,int listId,String[] key,int[] childId){ this.context=context; this.list=list; this.listId=listId; this.key=key; this.childId=childId; }}
2026年09月23日 16:24
有1个网友回答
网友(1):

public static void setAdapter(MySimpleAdapter adapter)改为
public void setAdapter(MySimpleAdapter adapter)