Reputation: 12204
I have a grid of TextViews
shown inside a TableLayout
. When the user taps a TextView
I need to change the cell's background by adding an ImageView
that will go to another cell when other cells will be clicked.
Which is the best way to do this in Android?
Upvotes: 2
Views: 1343
Reputation: 21639
TextView can have an image (drawable) as a background. So it is easy to do it with textView.setBackgroundDrawable(R.drawable.myimage);
You can move the image into any cell-textView with this method and set the previous to another image or nothing with textView.setBackgroundDrawable(null);
You cannot animate this movement in the table, because each row is one view an may limit the animation of its children views to its constrains.
Upvotes: 1
Reputation: 2881
This is a simple algorithm to solve your problem.
Get two taps positions and swap the corresponding image ids in array and reload all images as like as array in table.
If u follow this u will get.
Upvotes: 0
Reputation: 57682
Sounds like a puzzle you want do implemenent...
You should do the following to achieve what you want
Upvotes: 0