Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.example.aplikacja3;
- import androidx.appcompat.app.AppCompatActivity;
- import android.os.Bundle;
- import android.util.Log;
- import android.view.View;
- import android.widget.TextView;
- import org.w3c.dom.Text;
- public class MainActivity extends AppCompatActivity {
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- }
- int orderCount=0;
- public void sendOrder(View view) {
- ++orderCount;
- TextView textView = (TextView) findViewById(R.id.order_count);
- textView.setText(""+orderCount);
- }
- //Log.d("HelloWorldApplication", "orderCount: "+ orderCount)
- }
- --------------------
- <?xml version="1.0" encoding="utf-8"?>
- <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto"
- xmlns:tools="http://schemas.android.com/tools"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- tools:context=".MainActivity">
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical">
- <TextView
- android:id="@+id/textView"
- android:layout_width="64dp"
- android:layout_height="38dp"
- android:text="Ilość"
- android:textSize="24sp" />
- <TextView
- android:id="@+id/order_count"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="0"
- android:textSize="24sp" />
- <Button
- android:id="@+id/button"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:onClick="sendOrder"
- android:text="Zamów" />
- </LinearLayout>
- </androidx.constraintlayout.widget.ConstraintLayout>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement