I’m overriding the getItemViewType() method in my project to indicate which view to use for items in my list, R.layout.listview_item_product_complete or R.layout.listview_item_product_inprocess
I know this function must return a value between 0 and 1 less than the number of possible views, in my case 0 or 1.
How do I know which layout is 0 and which is 1? I presume the first layout I created will be 0 and the latter one 1, but I want to return a variable so that this value is flexible…
I.e.
@Override
public int getItemViewType(int position) {
// Define a way to determine which layout to use
if(//test for inprocess){
return INPROCESS_TYPE_INDEX;
} else {
return COMPLETE_TYPE_INDEX;
}
}
What/where can I reference to define the values for COMPLETE_TYPE_INDEX and INPROCESS_TYPE_INDEX ?
Honestly, it doesn’t matter whether
COMPLETE_TYPE_INDEXis 0 andINPROCESS_TYPE_INDEXis 1, or vica versa. But you define them as class variables, in this case they can bestaticandfinalas well: