L
Lucius1972
Neues Mitglied
- 0
Hallo Leute,
Ich habe eine ExpandableListview die in einem TabFragment liegt, das Tabfragment ist wieder teil meiner MainActivity.
Beim intialisieren bekomme Ich haber eine NullPointerException weil "inflater" null ist.
Habe schon versucht den context von meiner MainActivity zu uebergeben aber das klappt nicht.
Danke fuer eure Hilfe.
Mein TabFragment:
Ich habe eine ExpandableListview die in einem TabFragment liegt, das Tabfragment ist wieder teil meiner MainActivity.
Beim intialisieren bekomme Ich haber eine NullPointerException weil "inflater" null ist.
Habe schon versucht den context von meiner MainActivity zu uebergeben aber das klappt nicht.
Danke fuer eure Hilfe.
Code:
public class MyExpandableListAdapter extends BaseExpandableListAdapter {
private final SparseArray<Group> groups;
public LayoutInflater inflater;
public Activity activity;
public MyExpandableListAdapter(Activity act, SparseArray<Group> groups) {
this.activity = act;
this.groups = groups;
inflater = act.getLayoutInflater(); <----- NullPointerException
}
....
}
Code:
public class TabFragment1 extends Fragment {
Context con;
View v;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
v=inflater.inflate(R.layout.tab_fragment_1, container, false);
SparseArray<Group> groups = new SparseArray<Group>();
ExpandableListView listView = (ExpandableListView) v.findViewById(R.id.listView);
MyExpandableListAdapter adapter = new MyExpandableListAdapter((Activity) con, groups);
listView.setAdapter(adapter);
return inflater.inflate(R.layout.tab_fragment_1, container, false);
}
}