button - Replacing a View in Android onClick -
i'm still kind of new android. i'm writing tic tac toe game bit of practice. i'm trying figure out how replace views when click button. have 9 buttons in gridview. when user clicks one, want change non-clickable textview , button when user click's reset button @ bottom of screen.. use flag keep track of player's turn it'll know whether or not place x or o. possible or stretching here?
you'll find there not many things stretching android.
this possible. each grid in gridview
, put in 2 elements - button
, , textview
. change visibility of each. in other words, don't replace 1 other - hide one, , show other.
so you'd have 2 items this:
<button ... android:visibility="invisible"/> <textview ... android:visibility="visibile"/>
and have both of these match_parent
, fill each grid , both on top of each other.
to change visibility in code:
button1.setvisibility(view.invisible); textview1.setvisibility(view.visible);
i'm trying give little actual code possible play , write yourself, should put in right direction. let me know if need more guidance though.
Comments
Post a Comment