Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?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">
- <EditText
- android:id="@+id/editText01"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textSize="15pt"
- android:ems="5"
- android:inputType="number"
- app:layout_constraintLeft_toLeftOf="parent"
- app:layout_constraintTop_toTopOf="parent"
- android:layout_margin="5pt"
- />
- <TextView
- android:id="@+id/textView01"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="dni"
- android:textSize="15pt"
- app:layout_constraintLeft_toRightOf="@+id/editText01"
- app:layout_constraintBottom_toBottomOf="@id/editText01"
- android:layout_margin="5pt"
- />
- <EditText
- android:id="@+id/editText02"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textSize="15pt"
- android:ems="5"
- android:inputType="number"
- app:layout_constraintLeft_toLeftOf="parent"
- app:layout_constraintTop_toBottomOf="@id/editText01"
- android:layout_margin="5pt"
- />
- <TextView
- android:id="@+id/textView02"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="godziny"
- android:textSize="15pt"
- app:layout_constraintLeft_toRightOf="@+id/editText01"
- app:layout_constraintBottom_toBottomOf="@id/editText02"
- android:layout_margin="5pt"
- />
- <EditText
- android:id="@+id/editText03"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textSize="15pt"
- android:ems="5"
- android:inputType="number"
- app:layout_constraintLeft_toLeftOf="parent"
- app:layout_constraintTop_toBottomOf="@id/editText02"
- android:layout_margin="5pt"
- />
- <TextView
- android:id="@+id/textView03"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="minuty"
- android:textSize="15pt"
- app:layout_constraintLeft_toRightOf="@+id/editText01"
- app:layout_constraintBottom_toBottomOf="@id/editText03"
- android:layout_margin="5pt"
- />
- <Button
- android:id="@+id/button01"
- android:layout_width="0pt"
- android:layout_height="wrap_content"
- android:text="przelicz"
- android:textSize="10pt"
- android:layout_margin="5pt"
- app:layout_constraintTop_toBottomOf="@id/editText03"
- app:layout_constraintLeft_toLeftOf="parent"
- app:layout_constraintRight_toRightOf="parent"
- android:onClick="calculate"
- />
- <TextView
- android:id="@+id/textView04"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="................."
- android:textSize="12pt"
- android:ems="5"
- app:layout_constraintLeft_toLeftOf="parent"
- app:layout_constraintTop_toBottomOf="@id/button01"
- android:layout_margin="5pt"
- />
- <TextView
- android:id="@+id/textView05"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="minut"
- android:textSize="15pt"
- app:layout_constraintLeft_toRightOf="@id/textView04"
- app:layout_constraintTop_toBottomOf="@id/button01"
- android:layout_margin="5pt"
- />
- </androidx.constraintlayout.widget.ConstraintLayout>
- ***********************************************************************************
- package com.example.k02;
- import androidx.appcompat.app.AppCompatActivity;
- import android.os.Bundle;
- import android.view.View;
- import android.widget.EditText;
- 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);
- }
- public void calculate(View view) {
- double x=0, y=0, z=0;
- EditText dni = findViewById(R.id.editText01);
- EditText godz = findViewById(R.id.editText02);
- EditText min = findViewById(R.id.editText03);
- TextView wynik = findViewById(R.id.textView04);
- String dni1, godz1, min1;
- dni1 = dni.getText().toString();
- x = Double.parseDouble(dni1);
- godz1 = godz.getText().toString();
- y = Double.parseDouble(godz1);
- min1 = min.getText().toString();
- z = Double.parseDouble(min1);
- x=x*24*60;
- y=y*60;
- double w = x + y + z;
- wynik.setText(String.valueOf(w));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement