Reusing images in same layout

Go To


I was wondering if it was possible to reuse the same imageview more then once on the same layout.

Example: I'm working on a tic tac toe game for android in eclipse. I have drawn the table, x's, o's to give more of a visual appeal. I want to reuse the x's o's instead of creating x1..x9 and o1..o9 can I reuse a imageview and specify where I want it to be positioned?


2012-04-03 23:05
by s.nguyen


No, I'm afraid you can't.. but more realistically, wouldn't you just want square1...square9 and set that square's source? for example, something like:

public void onClick(View v) {
  ImageView square = (ImageView) v;
  if(lastClickWasO) {
    lastClickWasO = false;
  else {
    lastClickWasO = true;
2012-04-03 23:21
by JRaymond