I am developing an animation app like Mine Sweeper. Upon tapping on the buttons, the buttons will be pressed and the user may tap on the other button. On the third tap on the chosen button, there will be an incoming image (which uses AlphaAnimation/ScaleAnimation) from that button.
Buttons
private int[] right_lung = { R.id.lungs_106, R.id.lungs_113,
R.id.lungs_114, R.id.lungs_115, R.id.lungs_116, R.id.lungs_121,
R.id.lungs_122, R.id.lungs_123, R.id.lungs_124, R.id.lungs_125,
R.id.lungs_129, R.id.lungs_130, R.id.lungs_131, R.id.lungs_132,
R.id.lungs_133, R.id.lungs_134, R.id.lungs_137, R.id.lungs_138,
R.id.lungs_139, R.id.lungs_140, R.id.lungs_141, R.id.lungs_142,
R.id.lungs_145, R.id.lungs_146, R.id.lungs_147, R.id.lungs_148,
R.id.lungs_149, R.id.lungs_150, R.id.lungs_151, R.id.lungs_152,
R.id.lungs_153, R.id.lungs_154, R.id.lungs_155, R.id.lungs_156,
R.id.lungs_157, R.id.lungs_158, R.id.lungs_159, R.id.lungs_160,
R.id.lungs_161, R.id.lungs_162, R.id.lungs_163, R.id.lungs_164,
R.id.lungs_165, R.id.lungs_166, R.id.lungs_167, R.id.lungs_168,
R.id.lungs_169, R.id.lungs_170, R.id.lungs_171, R.id.lungs_172,
R.id.lungs_173, R.id.lungs_174, R.id.lungs_175, R.id.lungs_176,
R.id.lungs_177, R.id.lungs_178, R.id.lungs_179, R.id.lungs_180,
R.id.lungs_181, R.id.lungs_182, R.id.lungs_183, R.id.lungs_184,
R.id.lungs_185, R.id.lungs_186, R.id.lungs_187, R.id.lungs_188,
R.id.lungs_189, R.id.lungs_190, R.id.lungs_191, R.id.lungs_192,
R.id.lungs_194, R.id.lungs_195, R.id.lungs_196, R.id.lungs_197,
R.id.lungs_198, R.id.lungs_199, R.id.lungs_200, R.id.lungs_205,
R.id.lungs_206, R.id.lungs_207 };
private Button[] button_right_lung = new Button[right_lung.length];
MainActivity
for (int i = 0; i < button_right_lung.length; i++) {
final int b = i;
button_right_lung[i].setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (counter == 1) {
show_first_page();
int[] startPosition = new int[2];
button_right_lung[b].getLocationOnScreen(startPosition);
int[] endPosition = new int[2];
button_right_lung[b].getLocationOnScreen(endPosition);
Animation anim = new ScaleAnimation(startPosition[1], 2000, endPosition[1], 2000);
anim.setDuration(3000);
img_Message1.setVisibility(View.VISIBLE);
img_Message1.startAnimation(anim);
}
});
}
Now, my question is, how can I get the coordinates of the selected button and will animate the image after the button is pressed?