在我的应用程序中,我尝试使用setter和getter方法填充轮子适配器,如我的Post类中所示。
类Post {
private String imageList;
private String country_name;
private String country_code;
public void setImageList ( String imageList){
this.imageList = imageList;
}
public String getImageList (){
return imageList;
}
public void setCountryName ( String country_name){
this.country_name = country_name;
}
public String getCountryName (){
return country_name;
}
...
}我的wheelAdapter类如下所示:
public class SecondWheelAdapter extends AbstractWheelTextAdapter {
ArrayList<convertor_pst> PostList = new ArrayList<convertor_pst>();
public ImageLoader imageLoader;
// Countries names
private String countries[] =
new String[] {"EUR", "USD","EUR", "USD","EUR", "USD","EUR", "USD","EUR", "USD","EUR", "USD"};
// Countries flags
private int flags[] = new int[] {R.drawable.eur, R.drawable.usd,R.drawable.eur, R.drawable.usd,R.drawable.eur, R.drawable.usd,R.drawable.eur, R.drawable.usd,R.drawable.eur, R.drawable.usd,R.drawable.eur, R.drawable.usd};
/**
* Constructor
*/
Convertor main;
public SecondWheelAdapter(Context context) {
super(context, R.layout.country_layout, NO_RESOURCE);
setItemTextResource(R.id.country_name);
}
@Override
public View getItem(int index, View cachedView, ViewGroup parent) {
View view = super.getItem(index, cachedView, parent);
ImageView img = (ImageView) view.findViewById(R.id.flag);
img.setImageResource(flags[index]);
return view;
}
@Override
public int getItemsCount() {
return countries.length;
}
@Override
protected CharSequence getItemText(int index) {
return countries[index];
}我正在尝试替换这个数组
// Countries names
private String countries[] =
new String[] {"EUR", "USD","EUR", "USD","EUR", "USD","EUR", "USD","EUR", "USD","EUR", "USD"};请给我一个提示或教程来遵循。我从github得到了这个轮子适配器,它附带了一个库,但我遇到了困难。
发布于 2013-04-12 15:38:29
优化的解决方案:
我建议您创建一个ArrayList,而不是管理不同的字符串数组或ArrayList,这样管理单个ArrayList会更容易。
我的意思是删除countries[]和flags[]并创建单一的ArrayList<Post>类型。
https://stackoverflow.com/questions/15965597
复制相似问题