Problem with expandable list adapter?

I figured it out. For anyone interested, all you have to do is put the "Context" declaration inside "MyExpandableListAdapter", and add "this" to the adapter declaration. See my code below: import android.os.

Bundle; import android.view. View; import android.view. ViewGroup; import android.widget.

TextView; import android.widget. ExpandableListView; import android.widget. ExpandableListAdapter; import android.widget.

BaseExpandableListAdapter; import android.view. LayoutInflater; import android.content. Context; public class hmenyActivity extends MyActivity { ExpandableListAdapter adapter; /** Called when the activity is first created.

*/ @Override public void onCreate(Bundle savedInstanceState) { super. OnCreate(savedInstanceState); setContentView(R.layout. Hmeny); adapter = new MyExpandableListAdapter(this); ExpandableListView listView = (ExpandableListView) findViewById(R.id.

ListView); listView. SetOnChildClickListener(new OnChildClickListener() { @Override public boolean onChildClick(ExpandableListView arg0, View arg1, int arg2, int arg3, long arg4) { Toast. MakeText(getBaseContext(), "Child clicked", Toast.

LENGTH_LONG).show(); return false; } }); listView. SetAdapter(adapter); } public class MyExpandableListAdapter extends BaseExpandableListAdapter { private String groups = { "Test1", "Test2", "Test3" }; private String children = { { "foo1", "foo2", "foo3" }, { "foo1", "foo2", "foo3" }, { "foo1", "foo2", "foo3" } }; //Add these lines to your code private Context context; public MyExpandableListAdapter(Context context) { this. Context = context; } public Object getChild(int groupPosition, int childPosition) { return childrengroupPositionchildPosition; } public long getChildId(int groupPosition, int childPosition) { return childPosition; } public int getChildrenCount(int groupPosition) { return childrengroupPosition.

Length; } public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) { if (convertView == null) { LayoutInflater infalInflater = (LayoutInflater) context . GetSystemService(Context. LAYOUT_INFLATER_SERVICE); convertView = infalInflater.

Inflate(R.layout. Underkat_layout, null); } TextView textView = (TextView) convertView. FindViewById(R.id.

TvChild); textView. SetText(getChild(groupPosition, childPosition).toString()); return convertView; } public Object getGroup(int groupPosition) { return groupsgroupPosition; } public int getGroupCount() { return groups. Length; } public long getGroupId(int groupPosition) { return groupPosition; } public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) { if (convertView == null) { LayoutInflater infalInflater = (LayoutInflater) context .

GetSystemService(Context. LAYOUT_INFLATER_SERVICE); convertView = infalInflater. Inflate(R.layout.

Kat_layout, null); } TextView textView = (TextView) convertView. FindViewById(R.id. TvGroup); textView.

SetText(getGroup(groupPosition).toString()); return convertView; } public boolean isChildSelectable(int groupPosition, int childPosition) { return true; } public boolean hasStableIds() { return true; } } }.

ExpandableListView listView = (ExpandableListView) findViewById(URL1. MakeText(getBaseContext(), "Child clicked", Toast. ConvertView = infalInflater.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions