android - Increment TextView with button click -
Thanks for the help, but I am still struggling. I did this:
Button in XML: Main code (in the end): Where do I get this code especially when I press the app crash button should keep? Build in your class: And then; If you need to "save" scores, then you have left the application, you need to share to show / update the stock.
& amp; Android: layout_centerHorizontal = "true" android: layout_marginTop = "43dp" Android: layout_width = "wrap_content" Android: layout_height = "wrap_content" Background = "@ Android: Color / White" Android: onClick = "incrementScore" Android: text = "@ string / player" />
context reference; TextView TV; Button incremental; Public zero growth score (bundle saved instenstate) {super.onCreate (SavedInstanceState); SetContentView (R.layout.fragment_home); TV = (TextView) FindViewById (R.id.textView1); Incrementer = (button) findViewById (R.id.button1); Context = this; . Incrementer.setOnClickListener (New View.OnClickListener) {@Override Public Zero onClick (see v) {string present_value_string = tv.getText () toString (); Integer present_value_int = Integer.parseInt (present_value_string); present_value_int ++; tv.setText (String.valueOf (present_value_int));}}); }
int Score = 0;
button.setOnClickListener (New OnClickListener () {@Override Public Zero onClick (see v) {// Scores like score operation operation = = increment_value; t1.setText ("" + score); }});
Comments
Post a Comment