Converted Fragments in Activities

This commit is contained in:
wiecktobi 2020-05-02 17:05:17 +02:00 committed by Marcel Schwarz
parent 65364dcf81
commit ad056e6507
7 changed files with 32 additions and 45 deletions

View File

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

View File

@ -11,7 +11,7 @@ class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
setContentView(R.layout.activity_home)
// val binding = DataBindingUtil.setContentView(this, R.layout.activity_main)
// val navController = this.findNavController(R.id.HostFragment)
// 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
import android.content.Intent
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.databinding.DataBindingUtil
import kotlinx.android.synthetic.main.fragment_login.view.*
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
/**
* 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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".home">
android:background="@color/background_grey"
tools:context=".MainActivity">
<!-- TODO: Update blank fragment layout -->
<TextView

View File

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

View File

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