private Context mContext;
private int[] colors = new int[] { Color.WHITE, 0x30aaaaaa };
private int[] dotColors = new int[7];
private List<Integer> sta;
private TasksDataSource datasource;
private int con=1000;
public Integer[] mThumbIds = {
R.drawable.green, R.drawable.green,
R.drawable.green, R.drawable.green,
R.drawable.green, R.drawable.green,
R.drawable.green, R.drawable.green,
R.drawable.green, R.drawable.green,
R.drawable.green, R.drawable.green,
R.drawable.green, R.drawable.green,
R.drawable.green
};
public ImageAdapter(Context context, List<Integer> content){
sta = content;
datasource = new TasksDataSource(context); //here
datasource.open();
mContext=context;
}
@Override
public int getCount() {
return mThumbIds.length;
}
@Override
public Object getItem(int position) {
return mThumbIds[position];
}
@Override
public long getItemId(int position) {
return 0;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
int[] st = new int[sta.size()];
ImageView imageView = new ImageView(mContext);
imageView.setImageResource(mThumbIds[position]);
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
imageView.setLayoutParams(new GridView.LayoutParams(20, 20));
return imageView;
}
我有動態intialisation一個環,其具有在前面的代碼中的一些改變動態地顯示多個圖像..我怎樣才能在網格視圖
public Integer[] mThumbIds = new Integer[con];
for(int i = 0;i < st.length;i++)
{
st[i] = sta.get(i);
Log.i("st::" + st[i]," ");
}
int ii=0,jj=0;
while(ii<con)
{
if(st[jj]==0)
{
mThumbIds[ii]=R.drawable.red;
}
else if(st[jj]==1)
{
mThumbIds[ii]=R.drawable.green;
}
else
{
mThumbIds[ii]=R.drawable.grey;
}
}
上述加成din't工作和運行無限地停下來。 我想要的是,當mThumbIds [ii]是1時,顯示紅色img wen mThumbIds [ii]是0,綠色,當mThumbIds [ii]是2時是綠色,我怎麼能實現這個?
當mThumbIds是一個整型並要求輸入字符串時,如何使用displayImage(mThumbIds [position])。嘗試時出現錯誤。 –
是的,它需要int值 – Raghunandan
@紅色檢查https://github.com/nostra13/Android-Universal-Image-Loader – Raghunandan