From c920569a28504124c860709a08db98a121fa1112 Mon Sep 17 00:00:00 2001 From: lonkaars Date: Sat, 3 Feb 2024 16:48:42 +0100 Subject: workshop week 1 klaar --- app/src/main/AndroidManifest.xml | 3 ++ .../lonkaars/bingo3/DisplayMessageActivity.java | 22 ++++++++++++++ .../java/com/lonkaars/bingo3/MainActivity.java | 22 ++++++++++---- .../main/res/layout/activity_display_message.xml | 12 ++++++++ app/src/main/res/layout/activity_main.xml | 34 ++++++++++++---------- 5 files changed, 72 insertions(+), 21 deletions(-) create mode 100644 app/src/main/java/com/lonkaars/bingo3/DisplayMessageActivity.java create mode 100644 app/src/main/res/layout/activity_display_message.xml 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 @@ -12,6 +12,9 @@ android:supportsRtl="true" android:theme="@style/Theme.Bingo3" tools:targetApi="31"> + 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 @@ + + + + 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 @@ - + + - - - +