Reputation: 3215
This is my code . l when i am running it,nothing comes on emulator screen. even i am passing value for parent group.
i put break point also on getGroupView but this method not get calling.
// class for value in parent group
public class ArrayForList
{
public static String[] grp ={"Car"};
}
// Activity
public class ExpandableActivity extends Activity {
ExpandableListView ev;
ExpandableAdapter adp;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_expandable);
ev = (ExpandableListView) findViewById(R.id.el);
ev.setAdapter(new ExpandableAdapter(this));
}
}
//Adapter
public class ExpandableAdapter extends BaseExpandableListAdapter {
Context myContext;
public ExpandableAdapter(Context con)
{
this.myContext = con;
}
@Override
public Object getChild(int groupPosition, int childPosition) {
// TODO Auto-generated method stub
return null;
}
@Override
public long getChildId(int groupPosition, int childPosition) {
// TODO Auto-generated method stub
return 0;
}
@Override
public View getChildView(int groupPosition, int childPosition,
boolean isLastChild, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
return null;
}
@Override
public int getChildrenCount(int groupPosition) {
// TODO Auto-generated method stub
return 0;
}
@Override
public Object getGroup(int groupPosition) {
// TODO Auto-generated method stub
return null;
}
@Override
public int getGroupCount() {
// TODO Auto-generated method stub
return 0;
}
@Override
public long getGroupId(int groupPosition) {
// TODO Auto-generated method stub
return groupPosition;
}
@Override
public View getGroupView(int groupPosition, boolean isExpanded,
View convertView, ViewGroup parent) {
if (convertView == null) {
LayoutInflater inflater = (LayoutInflater) myContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.group_row, null);
}
TextView tvGroupName = (TextView) convertView.findViewById(R.id.tv_group);
tvGroupName.setText(ArrayForList.grp[groupPosition]);
return convertView;
}
@Override
public boolean hasStableIds() {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean isChildSelectable(int groupPosition, int childPosition) {
// TODO Auto-generated method stub
return false;
}
}
//xml group_row
<TextView
android:id="@+id/tv_group"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
//xml main
<ExpandableListView
android:id="@+id/el"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
Upvotes: 2
Views: 3212
Reputation: 406
In ExpandableAdapter class change return value of some methods.like getGroupCount() return size 0,its change to group size. getGroup(int groupPosition),it also return null value, change value of group at groupPosition.
Upvotes: 8