赞
踩
- selectedTypeTextView.setOnClickListener(
- new OnClickListener() {
-
-
- @Override
- public void onClick(View v) {
- // 弹出popup window
- popupShow(v);
- }
- });
- }
- gridView.setOnItemClickListener(new OnItemClickListener() {
-
-
- @Override
- public void onItemClick(AdapterView<?> arg0, View view,
- int position, long arg3) {
- if (position == photoResourceIdArray.length - 1) {
- // 选择本地图库 相机
- showDialogCustom();
- } else {
- // 选择默认图片
- Intent intent = new Intent(
- MainActivity.this,
- PuzzleMain.class);
- intent.putExtra(GlobalConst.SELECT_PHOTO_ID, photoResourceIdArray[position]);
- intent.putExtra(GlobalConst.TYPE, type);
- startActivity(intent);
- }
- }
- });
- gridView.setOnItemClickListener(new OnItemClickListener() {
-
-
- @Override
- public void onItemClick(AdapterView<?> arg0, View view,
- int position, long arg3) {
- // 判断是否可移动
- if (GameUtil.isMoveable(position)) {
- // 交换点击Item与空格的位置
- GameUtil.swapItems(
- GameUtil.gridItemList.get(position),
- GameUtil.blankGridItem);
- // 重新获取图片
- recreateData();
- // 通知GridView更改UI
- puzzleGridViewAdapter.notifyDataSetChanged();
- // 更新步数
- stepCount++;
- stepCountTextView.setText("" + stepCount);
- // 判断是否成功
- if (GameUtil.isSuccess()) {
- // 将最后一张图显示完整
- recreateData();
- bitmapItemList.remove(TYPE * TYPE - 1);
- bitmapItemList.add(lastBitmap);
- // 通知GridView更改UI
- puzzleGridViewAdapter.notifyDataSetChanged();
- Toast.makeText(PuzzleMain.this, "拼图成功!",
- Toast.LENGTH_LONG).show();
- gridView.setEnabled(false);
- timer.cancel();
- timerTask.cancel();
- }
- }
- }
- });
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。