From d604d263d02ecad65dc2f08f59b6e817cb0e5fe8 Mon Sep 17 00:00:00 2001 From: lonkaars Date: Mon, 19 Feb 2024 14:38:55 +0100 Subject: added fragments --- .../com/lonkaars/bingo3/OrientationActivity.java | 6 ++++++ .../java/com/lonkaars/bingo3/PortraitFragment.java | 15 ++++++++++++++ app/src/main/res/layout-land/orientation_demo.xml | 23 --------------------- app/src/main/res/layout-land/portrait_fragment.xml | 23 +++++++++++++++++++++ app/src/main/res/layout/orientation_demo.xml | 17 +++++---------- app/src/main/res/layout/portrait_fragment.xml | 24 ++++++++++++++++++++++ 6 files changed, 73 insertions(+), 35 deletions(-) create mode 100644 app/src/main/java/com/lonkaars/bingo3/PortraitFragment.java delete mode 100644 app/src/main/res/layout-land/orientation_demo.xml create mode 100644 app/src/main/res/layout-land/portrait_fragment.xml create mode 100644 app/src/main/res/layout/portrait_fragment.xml diff --git a/app/src/main/java/com/lonkaars/bingo3/OrientationActivity.java b/app/src/main/java/com/lonkaars/bingo3/OrientationActivity.java index 960af18..114f66e 100644 --- a/app/src/main/java/com/lonkaars/bingo3/OrientationActivity.java +++ b/app/src/main/java/com/lonkaars/bingo3/OrientationActivity.java @@ -5,9 +5,15 @@ import android.os.Bundle; import androidx.appcompat.app.AppCompatActivity; public class OrientationActivity extends AppCompatActivity { + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.orientation_demo); + + PortraitFragment f = new PortraitFragment(); + getSupportFragmentManager().beginTransaction() + .replace(R.id.fragment_container, f) + .commit(); } } \ No newline at end of file diff --git a/app/src/main/java/com/lonkaars/bingo3/PortraitFragment.java b/app/src/main/java/com/lonkaars/bingo3/PortraitFragment.java new file mode 100644 index 0000000..6420883 --- /dev/null +++ b/app/src/main/java/com/lonkaars/bingo3/PortraitFragment.java @@ -0,0 +1,15 @@ +package com.lonkaars.bingo3; + +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import androidx.fragment.app.Fragment; + +public class PortraitFragment extends Fragment { + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + return inflater.inflate(R.layout.portrait_fragment, container, false); + } +} + diff --git a/app/src/main/res/layout-land/orientation_demo.xml b/app/src/main/res/layout-land/orientation_demo.xml deleted file mode 100644 index 65dec93..0000000 --- a/app/src/main/res/layout-land/orientation_demo.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout-land/portrait_fragment.xml b/app/src/main/res/layout-land/portrait_fragment.xml new file mode 100644 index 0000000..c4d0730 --- /dev/null +++ b/app/src/main/res/layout-land/portrait_fragment.xml @@ -0,0 +1,23 @@ + + + + + diff --git a/app/src/main/res/layout/orientation_demo.xml b/app/src/main/res/layout/orientation_demo.xml index 2b178d3..c013ebf 100644 --- a/app/src/main/res/layout/orientation_demo.xml +++ b/app/src/main/res/layout/orientation_demo.xml @@ -5,20 +5,13 @@ android:layout_width="match_parent" android:layout_height="match_parent"> - + \ No newline at end of file diff --git a/app/src/main/res/layout/portrait_fragment.xml b/app/src/main/res/layout/portrait_fragment.xml new file mode 100644 index 0000000..2b178d3 --- /dev/null +++ b/app/src/main/res/layout/portrait_fragment.xml @@ -0,0 +1,24 @@ + + + + + \ No newline at end of file -- cgit v1.2.3