当我滚动 ListView 时,有谁知道如何使半径始终显示在顶部?
我正在使用 BaseAdapter 来实现第一个和最后一个项目背景。
这是适配器代码,
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if(this.dataset != null && !this.dataset.isEmpty() && this.dataset.size() > 0){
if(convertView == null){
convertView = inflater.inflate(R.layout.corner_list_item_layout, null);
}
ViewHolder holder = (ViewHolder) convertView.getTag();
if(holder == null){
holder = new ViewHolder();
holder.item = (RelativeLayout) convertView.findViewById(R.id.corner_list_item_relativelayout);
holder.label = (TextView) convertView.findViewById(R.id.corner_list_item_label);
convertView.setTag(holder);
}
if (position == 0) {
if (position == (this.getCount() - 1)) {
holder.item.setBackgroundResource(R.drawable.app_list_corner_round_light);
} else {
holder.item.setBackgroundResource(R.drawable.app_list_corner_round_top_dark);
}
} else if (position == (this.getCount() - 1)) {
if(position % 2 == 0){
holder.item.setBackgroundResource(R.drawable.app_list_corner_round_bottom_dark);
}else{
holder.item.setBackgroundResource(R.drawable.app_list_corner_round_bottom_light);
}
} else {
if(position % 2 == 0){
holder.item.setBackgroundResource(R.drawable.app_list_corner_middle_dark);
}else{
holder.item.setBackgroundResource(R.drawable.app_list_corner_middle_light);
}
}
String str = String.valueOf(this.dataset.get(position));
holder.label.setText(str);
}
return convertView;
}`