Converted Fragments in Activities

This commit is contained in:
wiecktobi 2020-05-02 17:05:17 +02:00
parent 3abd63cda2
commit e78258597f
7 changed files with 32 additions and 45 deletions

View File

@ -9,6 +9,12 @@
android:roundIcon="@mipmap/ic_launcher_round" android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/AppTheme"> android:theme="@style/AppTheme">
<activity android:name=".login">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<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" />

View File

@ -11,7 +11,7 @@ class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main) setContentView(R.layout.activity_home)
// val binding = DataBindingUtil.setContentView(this, R.layout.activity_main) // val binding = DataBindingUtil.setContentView(this, R.layout.activity_main)
// val navController = this.findNavController(R.id.HostFragment) // val navController = this.findNavController(R.id.HostFragment)
// NavigationUI.setupActionBarWithNavController(this, navController) // NavigationUI.setupActionBarWithNavController(this, navController)

View File

@ -1,22 +0,0 @@
package de.hft.geotracker
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
/**
* A simple [Fragment] subclass.
*/
class home : Fragment() {
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_home, container, false)
}
}

View File

@ -1,25 +1,30 @@
package de.hft.geotracker package de.hft.geotracker
import android.content.Intent
import android.os.Bundle import android.os.Bundle
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.databinding.DataBindingUtil import android.widget.TextView
import kotlinx.android.synthetic.main.fragment_login.view.* import androidx.appcompat.app.AppCompatActivity
/** /**
* A simple [Fragment] subclass. * A simple [Fragment] subclass.
*/ */
class login : Fragment() { class login : AppCompatActivity() {
lateinit var login : TextView
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_login)
login = findViewById(R.id.button_login)
login.setOnClickListener {
login()
}
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?): View? {
// Inflate the layout for this fragment
// val binding = DataBindingUtil.inflate(inflater, R.layout.fragment_login, container, false)
// val binding = DataBindingUtil.inflate<FragmentTitleBinding>(inflater, R.layout.fragment_title, container, false)
return inflater.inflate(R.layout.fragment_login, container, false)
} }
private fun login() {
val intent = Intent(this, MainActivity::class.java)
startActivity(intent)
}
} }

View File

@ -5,7 +5,8 @@
android:id="@+id/frameLayout" android:id="@+id/frameLayout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context=".home"> android:background="@color/background_grey"
tools:context=".MainActivity">
<!-- TODO: Update blank fragment layout --> <!-- TODO: Update blank fragment layout -->
<TextView <TextView

View File

@ -4,6 +4,7 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@color/background_grey"
tools:context=".login"> tools:context=".login">
<EditText <EditText

View File

@ -9,14 +9,10 @@
android:id="@+id/login" android:id="@+id/login"
android:name="de.hft.geotracker.login" android:name="de.hft.geotracker.login"
android:label="fragment_login" android:label="fragment_login"
tools:layout="@layout/fragment_login" > tools:layout="@layout/activity_login" />
<action <activity
android:id="@+id/action_login_to_home" android:id="@+id/mainActivity"
app:destination="@id/home" /> android:name="de.hft.geotracker.MainActivity"
</fragment> android:label="activity_home"
<fragment tools:layout="@layout/activity_home" />
android:id="@+id/home"
android:name="de.hft.geotracker.home"
android:label="fragment_home"
tools:layout="@layout/fragment_home" />
</navigation> </navigation>