I need that my ListView support different layouts depending on some condition, but it's not working and layout is the same in every cell. Here is a part of my code that unfortunately isn't working:
public class CustomAdapter extends ArrayAdapter<String> {
private final Activity context;
private final String[] sSecondStartTimeArray;
private final String[] sSecondEndTimeArray;
private final String[] sSecondTitleArray;
private final String AllData2;
public CustomAdapter(Activity context,
String[] sSecondStartTimeArray, String[] sSecondEndTimeArray, String[] sSecondTitleArray, String AllData2) {
super(context, R.layout.relcell2main, sSecondStartTimeArray);
this.context = context;
this.sSecondStartTimeArray = sSecondStartTimeArray;
this.sSecondEndTimeArray = sSecondEndTimeArray;
this.sSecondTitleArray = sSecondTitleArray;
this.AllData2 = AllData2;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
LayoutInflater inflater = context.getLayoutInflater();
int resource;
switch (HTTPRequestSecond.GetSecondType(AllData2, position)) {
case "rest":
resource = R.layout.relcell2second;
break;
default:
resource = R.layout.relcell2main;
break;
}
convertView = inflater.inflate(resource, parent, false);
}
//some code (it's now working properly even without this part)
return convertView;
}
"rest" result exists, I checked. But not working anyway.