I have been tinkering with this problem for atleast 5 hours and I can't wrap my head around it. I have expandable listview and groupposition is always returned as 0. Because of that. HashMap from which I take data out is always starting with one value. I loged out childposition and groupposition in "getChildView" but it always starts with 0
@Override
public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
if(convertView == null){
CategoryItem x = (CategoryItem)getChild(groupPosition, childPosition);
Log.d("EGILS",Integer.toString(groupPosition)+" "+Integer.toString(childPosition));
LayoutInflater layoutInflater = (LayoutInflater)this._context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = layoutInflater.inflate(R.layout.child_row, null);
TextView name = (TextView)convertView.findViewById(R.id.child_Virsraksts);
TextView price = (TextView)convertView.findViewById(R.id.child_Cena);
name.setText(x.getItem_name());
price.setText("€"+Double.toString(GV.round(x.getPrice_notax(),2)));
}
//return secondlvl;
return convertView;
}
This is the function that im getting my childView out, after that getChild
@Override
public Object getChild(int groupPosition, int childPosition) {
Log.d("GINTS2", Integer.toString(childPosition) + " " + this.categoryItems.get(this.subcategories.get(groupPosition).getId()).get(childPosition).getItem_name());
return (Object)this.categoryItems.get(this.subcategories.get(groupPosition).getId()).get(childPosition);
}
The funny thing is that when i log out groupposition in get childview i allways get 0
//1st GROUP PRESSED
11-06 02:50:41.551 19665-19665/com.martinssinka.projektaizmaksas D/EGILS﹕ 0 0
11-06 02:50:41.561 19665-19665/com.martinssinka.projektaizmaksas D/EGILS﹕ 0 1
11-06 02:50:41.566 19665-19665/com.martinssinka.projektaizmaksas D/EGILS﹕ 0 2
11-06 02:50:41.571 19665-19665/com.martinssinka.projektaizmaksas D/EGILS﹕ 0 3
//2nd GROUP PRESSED
11-06 02:50:47.052 19665-19665/com.martinssinka.projektaizmaksas D/EGILS﹕ 0 0
//3rd GROUP PRESSED
11-06 02:50:50.533 19665-19665/com.martinssinka.projektaizmaksas D/EGILS﹕ 0 0
Logged out GetGroupView (group position)
11-06 12:07:17.609 30767-30767/com.martinssinka.projektaizmaksas D/GROUPPo﹕ 0 -
11-06 12:07:17.624 30767-30767/com.martinssinka.projektaizmaksas D/GROUPPo﹕ 1 -
11-06 12:07:17.624 30767-30767/com.martinssinka.projektaizmaksas D/GROUPPo﹕ 2 -
11-06 12:07:17.676 30767-30767/com.martinssinka.projektaizmaksas D/GROUPPo﹕ 0 -
11-06 12:07:17.676 30767-30767/com.martinssinka.projektaizmaksas D/GROUPPo﹕ 1 -
11-06 12:07:17.676 30767-30767/com.martinssinka.projektaizmaksas D/GROUPPo﹕ 2 -
11-06 12:07:17.677 30767-30767/com.martinssinka.projektaizmaksas D/GROUPPo﹕ 0 -
11-06 12:07:17.677 30767-30767/com.martinssinka.projektaizmaksas D/GROUPPo﹕ 1 -
11-06 12:07:17.683 30767-30767/com.martinssinka.projektaizmaksas D/GROUPPo﹕ 2 -
11-06 12:07:17.689 30767-30767/com.martinssinka.projektaizmaksas D/GROUPPo﹕ 0 -
11-06 12:07:17.691 30767-30767/com.martinssinka.projektaizmaksas D/GROUPPo﹕ 1 -
11-06 12:07:17.691 30767-30767/com.martinssinka.projektaizmaksas D/GROUPPo﹕ 2 -
11-06 12:07:17.725 30767-30767/com.martinssinka.projektaizmaksas D/GROUPPo﹕ 0 -
11-06 12:07:17.726 30767-30767/com.martinssinka.projektaizmaksas D/GROUPPo﹕ 1 -
11-06 12:07:17.726 30767-30767/com.martinssinka.projektaizmaksas D/GROUPPo﹕ 2 -
So what i did was created new project and copied all the classes and layouts into new project. And worked like a charm.
Don't know what happened, i assumed it was probably a glitch .