I am making an application where i need to swap images in grid view . here is the code ... how could i achieve swapping :
activity
public class GameActivity extends Activity
implements OnTouchListener
{
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//Intent intent = getIntent();
setContentView(R.layout.layout_game);
//create grid view
splitImage();
GridView gridView = new GridView(this);
gridView = (GridView)findViewById(R.id.grid_view);
final ImageAdapter images = new ImageAdapter(this,chunkedImages);
final GridView gV = gridView;
gridView.setAdapter(images);
gridView.setOnTouchListener(this);
}
public boolean onTouch(View v, MotionEvent me) {
switch(me.getAction())
{
case MotionEvent.ACTION_DOWN :
Toast.makeText(GameActivity.this, "down ", Toast.LENGTH_SHORT).show();
break;
case MotionEvent.ACTION_UP :
Toast.makeText(GameActivity.this, "up " , Toast.LENGTH_SHORT).show();
break;
case MotionEvent.ACTION_MOVE :
//Toast.makeText(GameActivity.this, "move", Toast.LENGTH_SHORT).show();
break;
}
return true;
}
}
on touching the image it gives toast as down and on removing the fingure gives up . But how to swap image i could not understand.