I am integrating expandable list view in my project. But unable to find the list size in getGroupView(). Android studio showing me compile time error 'No candidate found for method call mList.size()'
Here is the Adapter
public class TripViewAdapter extends BaseExpandableListAdapter {
Context context;
public ArrayList<TrunkPointModel> mList;
public void updateAdapter(ArrayList<TrunkPointModel> mList){
this.mList = mList;
notifyDataSetChanged();
}
public TripViewAdapter(Context context, ArrayList<TrunkPointModel> mList) {
this.context = context;
this.mList = mList;
}
@Override
public Object getChild(int groupPosition, int childPosition) {
ArrayList<EmployeeModel> empList = mList.get(groupPosition).getEmpList();
return empList.get(childPosition);
}
@Override
public long getChildId(int groupPosition, int childPosition) {
return childPosition;
}
@Override
public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
final EmployeeModel expandedListText = (EmployeeModel) getChild(groupPosition, childPosition);
if (convertView == null) {
LayoutInflater layoutInflater = (LayoutInflater) this.context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = layoutInflater.inflate(R.layout.item_group1_child, null);
}
TextView txtEmpName = convertView.findViewById(R.id.txt_emp_name);
txtEmpName.setText(expandedListText.getName());
return convertView;
}
@Override
public int getChildrenCount(int groupPosition) {
ArrayList<EmployeeModel> empList = mList.get(groupPosition).getEmpList();
return empList.size();
}
@Override
public Object getGroup(int groupPosition) {
return mList.get(groupPosition);
}
@Override
public int getGroupCount() {
return mList.size();
}
@Override
public long getGroupId(int groupPosition) {
return groupPosition;
}
@Override
public View getGroupView(int groupPosition, boolean isLastChild, View convertView, ViewGroup parent) {
TrunkPointModel mList = (TrunkPointModel) getGroup(groupPosition);
if (convertView == null) {
LayoutInflater layoutInflater = (LayoutInflater) this.context.
getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = layoutInflater.inflate(R.layout.item_group1, null);
}
TextView txtGroupTitle = (TextView) convertView.findViewById(R.id.txt_group_title);
View viewStart = convertView.findViewById(R.id.view_start);
View viewEnd = convertView.findViewById(R.id.view_end);
txtGroupTitle.setTypeface(null, Typeface.BOLD);
txtGroupTitle.setText(mList.getTrunkPoint());
if (groupPosition == 0) {
viewEnd.setVisibility(View.INVISIBLE);
viewStart.setVisibility(View.VISIBLE);
viewStart.setBackgroundColor(Color.parseColor("#179402"));//green
} else if (groupPosition == mList.size() - 1) {
viewStart.setVisibility(View.INVISIBLE);
viewEnd.setVisibility(View.VISIBLE);
viewEnd.setBackgroundColor(Color.parseColor("#C3C3C3"));//gray
} else {
viewEnd.setVisibility(View.VISIBLE);
viewStart.setVisibility(View.VISIBLE);
viewEnd.setBackgroundColor(Color.parseColor("#C3C3C3"));
viewStart.setBackgroundColor(Color.parseColor("#C3C3C3"));
}
return convertView;
}
@Override
public boolean hasStableIds() {
return true;
}
@Override
public boolean isChildSelectable(int groupPosition, int childPosition) {
return true;
}
}
Whereas it is working fine in previous project. Not able to understand why. Even I have made list public
Any help is appreciated!
Thanks in Advance