我做了網格視圖,並都在繪製現在我想的是這些圖像來隨機圖像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