三个private final int one=0;
private final int two=1;
private final int three=2;
@Override
public int getItemViewType(int position) {
if (position%30){
return three;
}else if (position%3
2){
return two;
}else {
return one;
}
}

@Override
public int getViewTypeCount() {
    return 3;
}

侧拉适配器
private Context context;
private String[] list;
private final int one=0;
private final int two=1;

public MyclAdapter(Context context) {
    this.context = context;
    list=context.getResources().getStringArray(R.array.page_name);
}

@Override
public int getCount() {
    return list.length+1;
}

@Override
public String getItem(int position) {
    if (position==0){
        return \"\";
    }
    return list[position-1];
}

@Override
public int getViewTypeCount() {
return 2;
}

@Override
public int getItemViewType(int position) {
    if (position==one){
        return one;
    }else {
        return two;
    }
}

两个
public int getViewTypeCount() {
return 2;
}

@Override
public int getItemViewType(int position) {
    if (position %2 == 0) {
        return 0;
    }else {
        return 1;
    }
}
收藏 打印