
I want to define letters in a grid and then highlight it on selected and if it a valid word.
i can define the letters and show in a grid view.But how to highlight the word as in the figure on selection??
i am developing similar app.Please help.
i copied the image from Word Search App on Android Market.
You can do this using for loops for each row & col.
But here you will ahve to take many things under consideration for element :
If the elements are selected in straight row or col, you can set the background of all grid elements directly. BUT if it is selected diagonally, then you will have to color accrdingly using Drawable. You can create a drawable programmatically of specified color and work out.
UPDATED :
In XML, just give the gridLayout.
In activity in onCreate(), you can work out like this to add contents :
This will give you a startup on your problem. Start and try out.
You can also add all the components in XML instead of adding it via code. But that will make your XML very long and messy too.
If you get stuck up, feel free. For improvements, you cna create a method to create the button view and just call teh method in inner for loop. But go for this once you are succeded in generating what you want.
But don’t forget to start and try out first.