public class FavGarallyMyLableAdapter extends BaseAdapter {
/*
* 内部UI使用的数据结构 - 和界面有关
*/
private class ListItemUI {
TextView title;
ImageView image;
/*
public ImageView image;
public TextView title;
public TextView info;
*/
}
private List<ListItemUI> mListItemsUI = new ArrayList<ListItemUI>();
private int mFocusIdx=-1 ;
private List<GarallyItemMyLableData> mListItemData = new ArrayList<GarallyItemMyLableData>();
private Activity mActivity;
/*
* 初始化
*/
public FavGarallyMyLableAdapter(Activity activity) {
mActivity = activity;
//FavUsrLoadTestData(); //加载测试数据
}
/*
* 中途的刷新
*/
public void SetFocus(int val) {
mFocusIdx = val;
this.notifyDataSetChanged();
}
@Override
public int getCount() {
//return mListItemData.size();
return 13;
}
@Override
public Object getItem(int position) {
return position;
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
View view = mActivity.getLayoutInflater().inflate(R.layout.fav_garally_item_mylable, null);
ListItemUI cache = new ListItemUI();
cache.title = (TextView) view.findViewById(R.id.title);
if(position==0){
cache.title.setText("时政");
}
if(position==1){
cache.title.setText("经济");
;
}
if(position==2){
cache.title.setText("区县");
}
if(position==3){
cache.title.setText("民生");
cache.image = (ImageView) view.findViewById(R.id.image);
cache.image.setBackgroundResource(R.drawable.newsbtg);
if(mFocusIdx == position){
cache.image.setVisibility(View.VISIBLE);
}
else{
cache.image.setVisibility(View.GONE);
}
mListItemsUI.add(cache);
return view;
}
}