Advertisement
Guest User

Untitled

a guest
Feb 28th, 2020
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.04 KB | None | 0 0
  1. package com.example.aplikacja3;
  2.  
  3. import androidx.appcompat.app.AppCompatActivity;
  4.  
  5. import android.os.Bundle;
  6. import android.util.Log;
  7. import android.view.View;
  8. import android.widget.TextView;
  9.  
  10. import org.w3c.dom.Text;
  11.  
  12. public class MainActivity extends AppCompatActivity {
  13.  
  14. @Override
  15. protected void onCreate(Bundle savedInstanceState) {
  16. super.onCreate(savedInstanceState);
  17. setContentView(R.layout.activity_main);
  18. }
  19.  
  20. int orderCount=0;
  21. public void sendOrder(View view) {
  22. ++orderCount;
  23. TextView textView = (TextView) findViewById(R.id.order_count);
  24. textView.setText(""+orderCount);
  25. }
  26. //Log.d("HelloWorldApplication", "orderCount: "+ orderCount)
  27. }
  28.  
  29. --------------------
  30. <?xml version="1.0" encoding="utf-8"?>
  31. <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
  32. xmlns:app="http://schemas.android.com/apk/res-auto"
  33. xmlns:tools="http://schemas.android.com/tools"
  34. android:layout_width="match_parent"
  35. android:layout_height="match_parent"
  36. tools:context=".MainActivity">
  37.  
  38. <LinearLayout
  39. android:layout_width="match_parent"
  40. android:layout_height="match_parent"
  41. android:orientation="vertical">
  42.  
  43. <TextView
  44. android:id="@+id/textView"
  45. android:layout_width="64dp"
  46. android:layout_height="38dp"
  47. android:text="Ilość"
  48. android:textSize="24sp" />
  49.  
  50. <TextView
  51. android:id="@+id/order_count"
  52. android:layout_width="wrap_content"
  53. android:layout_height="wrap_content"
  54. android:text="0"
  55. android:textSize="24sp" />
  56.  
  57. <Button
  58. android:id="@+id/button"
  59. android:layout_width="wrap_content"
  60. android:layout_height="wrap_content"
  61. android:onClick="sendOrder"
  62. android:text="Zamów" />
  63.  
  64. </LinearLayout>
  65.  
  66. </androidx.constraintlayout.widget.ConstraintLayout>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement