Hello. I have a problem. There is a variable int sitost = 25; I want to make it so that when I click on button1, the sitost variable adds + 10. I do it this way, but the value does not add:
The code for the gameview.xml file:
<TextView android:id="@+id/sitost" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="TextView" /> <Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:onClick="plus" android:text="Button" />GameView.java file code:
public class GameView extends Activity { TextView SitostCat; int sitcoll = 25; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); /* Скрываем строку состояния */ requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.gameview); SitostCat = (TextView) findViewById(R.id.sitost); SitostCat.setText("Сытость " + sitcoll); } public void plus(View view) { switch (view.getId()) { case R.id.button1: sitcoll = sitcoll + 10; break; } }
When you click on the button, nothing happens. What's my mistake? I would be very grateful for the help!
TextViewsitost)? - Dmi7ry