Added Log Out function and Settings activity
This commit is contained in:
@@ -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);
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user