public class ScenesActivity extends Activity implements Animation.AnimationListener, View.OnClickListener {
private Button mBack;
private Button mExit;
private Button mAbout;
private GridView gridView;
private GridViewAdapter customGridAdapter;
private int mCurrentAnimationObjectNumber = 0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.scenes_grid);
initializeClicks();
gridView = (GridView) findViewById(R.id.gridView);
customGridAdapter = new GridViewAdapter(this, R.layout.row_grid, getData());
gridView.setAdapter(customGridAdapter);
gridView.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View v,
int position, long id) {
Toast.makeText(ScenesActivity.this, position + "#Selected",
Toast.LENGTH_SHORT).show();
}
});
initializeClicks();
}
private ArrayList<ImageItem> getData() {
final ArrayList<ImageItem> imageItems = new ArrayList<ImageItem>();
TypedArray imgs = getResources().obtainTypedArray(R.array.image_ids);
Bitmap farmAnimals = BitmapFactory.decodeResource(this.getResources(), imgs.getResourceId(0, -1));
imageItems.add(new ImageItem(farmAnimals, "Farm Animals"));
Bitmap fruitsVeg = BitmapFactory.decodeResource(this.getResources(), imgs.getResourceId(1, -1));
imageItems.add(new ImageItem(fruitsVeg, "Fruits & Vegetables"));
Bitmap childrenRoom = BitmapFactory.decodeResource(this.getResources(), imgs.getResourceId(2, -1));
imageItems.add(new ImageItem(childrenRoom, "Children Room"));
Bitmap beach = BitmapFactory.decodeResource(this.getResources(), imgs.getResourceId(3, -1));
imageItems.add(new ImageItem(beach, "Beach"));
Bitmap transport = BitmapFactory.decodeResource(this.getResources(), imgs.getResourceId(4, -1));
imageItems.add(new ImageItem(transport, "transport"));
return imageItems;
}
private void initializeClicks(){
mBack = (Button) findViewById(R.id.back);
mExit = (Button) findViewById(R.id.exit);
mAbout = (Button) findViewById(R.id.about);
mBack.setOnClickListener(this);
mExit.setOnClickListener(this);
mAbout.setOnClickListener(this);
}
プロセスをクリックしScenesActivity
た後、予期せず停止しました。コードをデバッグしましたが、メソッドでクリックリスナーを設定しようとすると問題が発生しますinitializeClicks()
。解決方法がわかりません。誰かがこの問題を解決できますか?