diff options
author | lonkaars <loek@pipeframe.xyz> | 2024-02-03 16:48:42 +0100 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2024-02-03 16:48:42 +0100 |
commit | c920569a28504124c860709a08db98a121fa1112 (patch) | |
tree | 8703147173312fb020084601e6d58299ded6ad2c | |
parent | 3e17e1a4132ed11c6a5ab66dca8840586061b90d (diff) |
workshop week 1 klaar
-rw-r--r-- | app/src/main/AndroidManifest.xml | 3 | ||||
-rw-r--r-- | app/src/main/java/com/lonkaars/bingo3/DisplayMessageActivity.java | 22 | ||||
-rw-r--r-- | app/src/main/java/com/lonkaars/bingo3/MainActivity.java | 22 | ||||
-rw-r--r-- | app/src/main/res/layout/activity_display_message.xml | 12 | ||||
-rw-r--r-- | app/src/main/res/layout/activity_main.xml | 34 |
5 files changed, 72 insertions, 21 deletions
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 08e7139..8f8a7c3 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -13,6 +13,9 @@ android:theme="@style/Theme.Bingo3" tools:targetApi="31"> <activity + android:name=".DisplayMessageActivity" + android:exported="false" /> + <activity android:name=".MainActivity" android:exported="true"> <intent-filter> diff --git a/app/src/main/java/com/lonkaars/bingo3/DisplayMessageActivity.java b/app/src/main/java/com/lonkaars/bingo3/DisplayMessageActivity.java new file mode 100644 index 0000000..d2c12f1 --- /dev/null +++ b/app/src/main/java/com/lonkaars/bingo3/DisplayMessageActivity.java @@ -0,0 +1,22 @@ +package com.lonkaars.bingo3; + +import androidx.appcompat.app.AppCompatActivity; + +import android.content.Intent; +import android.os.Bundle; +import android.widget.TextView; + +public class DisplayMessageActivity extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_display_message); + + Intent intent = getIntent(); + String message = intent.getStringExtra(Intent.EXTRA_TEXT); + + TextView textView = findViewById(R.id.textView); + textView.setText(message); + } +} diff --git a/app/src/main/java/com/lonkaars/bingo3/MainActivity.java b/app/src/main/java/com/lonkaars/bingo3/MainActivity.java index 1bb8365..5e75ecd 100644 --- a/app/src/main/java/com/lonkaars/bingo3/MainActivity.java +++ b/app/src/main/java/com/lonkaars/bingo3/MainActivity.java @@ -2,13 +2,25 @@ package com.lonkaars.bingo3; import androidx.appcompat.app.AppCompatActivity; +import android.content.Intent; import android.os.Bundle; +import android.view.View; +import android.widget.EditText; public class MainActivity extends AppCompatActivity { - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); - } + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + } + + public void send(View view) { + EditText editText = findViewById(R.id.edit_message); + String message = editText.getText().toString(); + + Intent intent = new Intent(this, DisplayMessageActivity.class); + intent.putExtra(Intent.EXTRA_TEXT, message); + startActivity(intent); + } } diff --git a/app/src/main/res/layout/activity_display_message.xml b/app/src/main/res/layout/activity_display_message.xml new file mode 100644 index 0000000..c44487f --- /dev/null +++ b/app/src/main/res/layout/activity_display_message.xml @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical"> + <TextView + android:id="@+id/textView" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:gravity="center" + android:textSize="32sp"/> +</LinearLayout> diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index c75d057..fe42b62 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -1,18 +1,20 @@ <?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 xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="horizontal"> + <EditText + android:id="@+id/edit_message" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:ems="10" + android:hint="Your message here" + android:inputType="textPersonName"/> - <TextView - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Hello World!" - app:layout_constraintBottom_toBottomOf="parent" - app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toTopOf="parent" /> - -</androidx.constraintlayout.widget.ConstraintLayout> + <Button + android:id="@+id/button" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:onClick="send" + android:text="Send"/> +</LinearLayout> |