我做了网格视图,并都在绘制现在我想的是这些图像来随机图像9图像视图的我已经在网格视图,如以1秒之尽快感动用户显示一个图像它会消失,它在不同的图像视图中显示另一个图像,并继续。 请帮助,如果任何机构有想法。之后dis如何使图像随机出现在图像视图中。如何在android中使用timer来在gridview的不同图像视图中随机显示图像?
<
import android.content.Context;
import android.database.DataSetObserver;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.ListAdapter;
public class ImageAdapter extends BaseAdapter {
private Context mContext;
public ImageAdapter(Context c) {
mContext = c;
}
public int getCount() {
return mThumbIds.length;
}
public Object getItem(int position) {
return null;
}
public long getItemId(int position) {
return 0;
}
// create a new ImageView for each item referenced by the Adapter
public View getView(int position, View convertView, ViewGroup parent) {
ImageView imageView;
if (convertView == null) { // if it's not recycled, initialize some attributes
imageView = new ImageView(mContext);
imageView.setLayoutParams(new GridView.LayoutParams(85, 85));
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
imageView.setPadding(8, 8, 8, 8);
} else {
imageView = (ImageView) convertView;
}
imageView.setImageResource(mThumbIds[position]);
return imageView;
}
// references to our images
private Integer[] mThumbIds = {
R.drawable.sample_2, R.drawable.sample_3,
R.drawable.sample_4, R.drawable.sample_5,
R.drawable.sample_6, R.drawable.sample_7,
R.drawable.sample_0, R.drawable.sample_1,
R.drawable.sample_2, R.drawable.sample_3,
R.drawable.sample_4, R.drawable.sample_5,
R.drawable.sample_6, R.drawable.sample_7,
R.drawable.sample_0, R.drawable.sample_1,
R.drawable.sample_2, R.drawable.sample_3,
R.drawable.sample_4, R.drawable.sample_5,
R.drawable.sample_6, R.drawable.sample_7
};
}
>
你尝试过这么远吗?你遇到什么问题?请在你的问题上留出更多时间。 – Benoir 2012-08-01 18:00:05
喜请检查一下我已经修改了疑问句我希望这是更清楚你 – 2012-08-01 18:03:23
我觉得Benoir问你做了什么。我们不能为你做这个工作,哈哈。 – Andy 2012-08-01 18:15:15