在我的应用程序中,我正在尝试使用 setter 和 getter 方法填充车轮适配器,如我的 Post Class 中所示。
类帖子{
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"};
值存储在 ArrayList<> 但我不知道如何修改国家 [] 以便它接受来自我的 PostList.get(id).getCountryName(); 的数据 接下来我需要在 setItemTextResource(R.id.country_name); 中设置它
请给我一个提示或教程。我从 github 得到这个轮子适配器,它带有一个库,但我遇到了困难。