Tuesday, 15 March 2011

android - recording user selections and altering textview strings via java code -



android - recording user selections and altering textview strings via java code -

im new android programming (and java matter). although have grasp on programming concepts.

what im trying exercise help build understanding create simple text adventure. want begin offering user ability select player race or class (which determine how story plays out). plan on doing radio buttons (or perhaps normal button).

my question this. when user selects class (ie: "mage") want selection stored. there want able define conditional statement alter story user given. problem not yet have grasp on process recording users selection, , altering text in textview (or other view)

once know how record variable user chose , test in "if" statement, alter output of view within conditional, on way.

thanks in advance =)

first want create radio grouping in layout xml file , give each radio button id value reference java code this:

<radiogroup android:id="@+id/radgroup"> <radiobutton android:id="@+id/rad1" android:text="radio1"/> <radiobutton android:id="@+id/rad2" android:text="radio2"/> <radiobutton android:id="@+id/rad3" android:text="radio3"/> </radiogroup>

then there utilize if statement or switch statement , altering textview utilize mytextview.settext("mystring") , utilize within each if accomplish different text values.

java android xml eclipse input

No comments:

Post a Comment