Add button to main activity to start a login process

This commit is contained in:
Matthieu 2020-03-06 08:49:26 +01:00
parent 0892ff536f
commit d0ca08391b
5 changed files with 20 additions and 12 deletions

View File

@ -11,7 +11,7 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".Login"></activity>
<activity android:name=".LoginActivity"></activity>
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

View File

@ -16,7 +16,7 @@ import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response
class Login : AppCompatActivity() {
class LoginActivity : AppCompatActivity() {
private lateinit var preferences: SharedPreferences

View File

@ -1,22 +1,20 @@
package com.h.pixeldroid
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import com.h.pixeldroid.api.PixelfedAPI
import com.h.pixeldroid.objects.Status
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response
import retrofit2.Retrofit
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory
import retrofit2.converter.gson.GsonConverterFactory
import android.view.View
import android.widget.Button
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val button = findViewById<Button>(R.id.button_start_login)
button.setOnClickListener((View.OnClickListener {
val intent = Intent(this, LoginActivity::class.java)
startActivity(intent) }))
}
}

View File

@ -4,7 +4,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Login">
tools:context=".LoginActivity">
<Button
android:id="@+id/button"

View File

@ -7,6 +7,7 @@
tools:context=".MainActivity">
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
@ -15,4 +16,13 @@
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="@+id/button_start_login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="80dp"
android:text="start login"
app:layout_constraintStart_toStartOf="@+id/textView"
app:layout_constraintTop_toBottomOf="@+id/textView" />
</androidx.constraintlayout.widget.ConstraintLayout>