Added Log Out function and Settings activity

This commit is contained in:
AndrewTrieu
2022-12-01 12:07:32 +02:00
parent 8912ddad87
commit 3911795007
9 changed files with 129 additions and 54 deletions

View File

@@ -2,12 +2,17 @@ package com.example.electricity;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
public class Home extends AppCompatActivity {
String username;
TextView name, usage;
ImageView back, setting;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -16,5 +21,25 @@ public class Home extends AppCompatActivity {
name = findViewById(R.id.textView12);
name.setText(username);
usage = findViewById(R.id.textView11);
back = findViewById(R.id.imageView17);
setting = findViewById(R.id.imageView18);
logOut();
startSetting();
}
public void logOut() {
back.setOnClickListener(view -> {
Toast.makeText(Home.this, "Logged out successfully", Toast.LENGTH_LONG).show();
Intent intent = new Intent(this, MainActivity.class);
startActivity(intent);
finish();
});
}
public void startSetting() {
setting.setOnClickListener(view -> {
Intent intent = new Intent(this, Settings.class);
startActivity(intent);
});
}
}