Initial GUI

This commit is contained in:
_N0x 2021-06-29 13:45:28 +02:00
parent db63cbbfaf
commit 3187ea3aec
6 changed files with 204 additions and 5 deletions

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="GradleMigrationSettings" migrationVersion="1" />
<component name="GradleSettings"> <component name="GradleSettings">
<option name="linkedExternalProjectsSettings"> <option name="linkedExternalProjectsSettings">
<GradleProjectSettings> <GradleProjectSettings>

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_15_PREVIEW" default="false" project-jdk-name="15" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_14" default="false" project-jdk-name="15" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" /> <output url="file://$PROJECT_DIR$/build/classes" />
</component> </component>
<component name="ProjectType"> <component name="ProjectType">

View File

@ -9,10 +9,12 @@
android:roundIcon="@mipmap/ic_launcher_round" android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/Theme.Java_mot_testing"> android:theme="@style/Theme.Java_mot_testing">
<activity android:name=".ex9.FractionCalculator"/>
<activity android:name=".MainActivity"> <activity android:name=".MainActivity">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
</activity> </activity>

View File

@ -1,14 +1,19 @@
package io.n0x.android.java_mot_testing; package io.n0x.android.java_mot_testing;
import androidx.appcompat.app.AppCompatActivity; import android.app.Activity;
import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
public class MainActivity extends AppCompatActivity { import io.n0x.android.java_mot_testing.ex9.FractionCalculator;
public class MainActivity extends Activity {
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Intent intent = new Intent(this, FractionCalculator.class);
startActivity(intent);
} }
} }

View File

@ -0,0 +1,54 @@
package io.n0x.android.java_mot_testing.ex9;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.TextView;
import io.n0x.android.java_mot_testing.R;
public class FractionCalculator extends Activity{
private static final String TAG = FractionCalculator.class.getName();
private TextView txt_enum_left;
private TextView txt_denom_left;
private TextView txt_enum_right;
private TextView txt_denom_right;
private TextView txt_enum_result;
private TextView txt_denom_result;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.ex9_data_binding);
Log.d(TAG, "FractionCalculator started");
/*
txt_enum_left = (TextView) findViewById(R.id.txt_enum_left);
txt_denom_left = (TextView) findViewById(R.id.txt_denom_left);
txt_enum_right = (TextView) findViewById(R.id.txt_enum_right);
txt_denom_right = (TextView) findViewById(R.id.txt_denom_right);
txt_enum_result = (TextView) findViewById(R.id.txt_enum_result);
txt_denom_result = (TextView) findViewById(R.id.txt_denom_result);
// Set all fields to 0
txt_enum_left.setText("0");
txt_denom_left.setText("0");
txt_enum_right.setText("0");
txt_denom_right.setText("0");
txt_enum_result.setText("0");
txt_denom_result.setText("0");
//*/
}
@Override
protected void onStart() {
super.onStart();
}
}

View File

@ -0,0 +1,137 @@
<?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">
<Button
android:id="@+id/button_add"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="+"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="@+id/button_sub"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="-"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/button_add" />
<Button
android:id="@+id/button_mult"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="*"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/button_sub" />
<Button
android:id="@+id/button_div"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="/"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.501"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/button_mult" />
<TextView
android:id="@+id/txt_equals"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="48dp"
android:text="="
android:textSize="34sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.183"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/button_div" />
<TextView
android:id="@+id/txt_denom_result"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="3dp"
android:layout_marginBottom="412dp"
android:inputType="numberSigned"
android:numeric="integer"
android:text="TextView"
android:textAlignment="center"
android:textSize="34sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.247"
app:layout_constraintStart_toEndOf="@+id/txt_equals"
app:layout_constraintTop_toBottomOf="@+id/txt_enum_result" />
<TextView
android:id="@+id/txt_enum_result"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:numeric="integer"
android:text="TextView"
android:textAlignment="center"
android:textSize="34sp"
app:layout_constraintBottom_toTopOf="@+id/txt_denom_result"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.247"
app:layout_constraintStart_toEndOf="@+id/txt_equals"
app:layout_constraintTop_toBottomOf="@+id/button_div" />
<EditText
android:id="@+id/enumRight"
android:layout_width="140dp"
android:layout_height="50dp"
android:layout_marginTop="32dp"
android:ems="10"
android:hint="Zähler"
android:inputType="numberSigned"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/button_add"
app:layout_constraintTop_toTopOf="parent" />
<EditText
android:id="@+id/enumRight2"
android:layout_width="140dp"
android:layout_height="50dp"
android:layout_marginTop="32dp"
android:ems="10"
android:hint="Zähler"
android:inputType="numberSigned"
app:layout_constraintEnd_toStartOf="@+id/button_add"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<EditText
android:id="@+id/denomLeft"
android:layout_width="140dp"
android:layout_height="50dp"
android:layout_marginTop="32dp"
android:ems="10"
android:hint="Nenner"
android:inputType="number"
app:layout_constraintEnd_toStartOf="@+id/button_mult"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/enumRight2" />
<EditText
android:id="@+id/denomRight"
android:layout_width="140dp"
android:layout_height="50dp"
android:layout_marginTop="32dp"
android:ems="10"
android:hint="Nenner"
android:inputType="number"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/button_mult"
app:layout_constraintTop_toBottomOf="@+id/enumRight" />
</androidx.constraintlayout.widget.ConstraintLayout>