Code example for ImageButton

Methods: setImageBitmap, getTag

0
		btnVals[target] = srcTagVal;
		// change target ImageButton tag 
		ImageButton targetTile = ((ImageButton) findViewById(btnIds[target]));
		int destTagVal = Integer.parseInt(srcTile.getTag().toString());
		targetTile.setTag(srcTile.getTag());
		// swap imagebutton background 
		srcTile.setImageBitmap(tiles[destTagVal - 1]);
		targetTile.setImageBitmap(tiles[srcTagVal - 1]);
 
	} 
 
	/* If the drag and empty box are in the same direction returns true */ 
	private static final int RIGHT = 1;
	private static final int LEFT = 2;
	private static final int DOWN = 3;
	private static final int UP = 4;
 
	private boolean isValidTouch(int row, int col, final int dir) {
 
		final int eRow = mEmptyCell / DIM;
		final int eCol = mEmptyCell % DIM;