Commit 7c5ad26a authored by Wahyu Wibowo's avatar Wahyu Wibowo

add login

parents ae15cf50 66bd6084
package com.example.yourcashiertest.activities;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import com.example.yourcashiertest.R;
import com.google.android.material.button.MaterialButton;
import com.google.android.material.textfield.TextInputEditText;
public class LoginActivity extends AppCompatActivity {
TextInputEditText etUsername;
MaterialButton btnLogin;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
etUsername = findViewById(R.id.etUsername);
btnLogin = findViewById(R.id.btnLogin);
btnLogin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(LoginActivity.this, MainActivity.class);
intent.putExtra("username", etUsername.getText().toString());
startActivity(intent);
finish();
}
});
}
}
\ No newline at end of file
...@@ -14,7 +14,6 @@ import java.util.List; ...@@ -14,7 +14,6 @@ import java.util.List;
@Dao @Dao
public interface ProductDao { public interface ProductDao {
@Query("SELECT * FROM products ORDER BY id DESC") @Query("SELECT * FROM products ORDER BY id DESC")
public LiveData<List<Product>> getProducts(); public LiveData<List<Product>> getProducts();
......
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_margin="@dimen/space_default"
android:layout_height="match_parent"
tools:context=".activities.LoginActivity">
<com.google.android.material.textview.MaterialTextView
android:id="@+id/tvLogin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="25dp"
android:layout_marginTop="80dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:textStyle="bold"
android:text="Login"/>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/tilUsername"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@+id/tvLogin"
android:layout_marginTop="60dp"
android:layout_marginStart="@dimen/space_default"
android:layout_marginEnd="@dimen/space_default"
android:layout_marginBottom="@dimen/space_default">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/etUsername"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Masukkan username..."
android:inputType="textCapWords"
android:imeOptions="actionNext"
android:textSize="@dimen/text_default" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/tilPassword"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@+id/tilUsername"
android:layout_marginStart="@dimen/space_default"
android:layout_marginTop="20dp"
android:layout_marginEnd="@dimen/space_default"
android:layout_marginBottom="@dimen/space_default">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/etPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Masukkan password..."
android:inputType="textPassword"
android:textSize="@dimen/text_default" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.button.MaterialButton
android:id="@+id/btnLogin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Login"
android:backgroundTint="@color/colorPrimary"
app:layout_constraintTop_toBottomOf="@+id/tilPassword"
android:layout_marginTop="60dp"
app:layout_constraintEnd_toEndOf="parent"
android:padding="@dimen/space_default"
app:cornerRadius="@dimen/space_default"
android:layout_marginEnd="@dimen/space_default"/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment