Lumbes Finalproject
Lumbes Finalproject
Lumbes Finalproject
FINAL PROJECT
JAVA CODES(MAIN):
package com.example.myapplication;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
buttonLogin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String usernameLog = usernameOutside.getText().toString();
String passwordLog = passwordOutside.getText().toString();
if((usernameLog.equals("admin"))&&
(passwordLog.equals("admin") )) {
Intent intent = new Intent(main.this,
main2.class);
startActivity(intent);
}else{
Boolean checkUserPass =
mynewdbAdapter.checkusernamepassword(usernameLog, passwordLog);
if(checkUserPass) {
Boolean checkUserType =
mynewdbAdapter.checkuserType(usernameLog);
if(checkUserType) {
Intent intent = new Intent(main.this,
main3.class);
startActivity(intent);
}else{
Intent intent = new Intent(main.this,
main4.class);
startActivity(intent);
}
} else{
Toast.makeText(main.this, "Account doesn't exist.",
Toast.LENGTH_SHORT).show();
}
}
}
});
}
}
MAIN2:
package com.example.myapplication;
import androidx.appcompat.app.AppCompatActivity;
import android.app.AlertDialog;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Toast;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main2);
usernameInside = findViewById(R.id.usernameInside);
passwordInside = findViewById(R.id.passwordInside);
radios = findViewById(R.id.radios);
buttonAdd = findViewById(R.id.buttonAdd);
buttonView = findViewById(R.id.buttonView);
buttonDelete = findViewById(R.id.buttonDelete);
buttonUpdate = findViewById(R.id.buttonUpdate);
mynewdbAdapter = new myDbAdapter(this);
mynewdbAdapter.insertData("admin","admin","Super Admin");
new1 = findViewById(R.id.new1);
new2 = findViewById(R.id.new2);
buttonSubmitUpdate = findViewById(R.id.buttonSubmit);
logout = findViewById(R.id.logout);
buttonSubmitdelete = findViewById(R.id.buttonSubmitdelete);
Editdelete = findViewById(R.id.Editdelete);
buttonAdd.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
AJ.users = usernameInside.getText().toString();
String password = passwordInside.getText().toString();
String usertype =
((RadioButton)findViewById(radios.getCheckedRadioButtonId())).getText().toStr
ing();
Boolean checkUser = mynewdbAdapter.checkusername(AJ.users);
if ((AJ.users.isEmpty()) || (password.isEmpty())){
Toast.makeText(main2.this, "Please fill in all the
required fields.", Toast.LENGTH_SHORT).show();
} else{
if(!checkUser){//not true or not existing
Boolean insertData =
mynewdbAdapter.insertData(AJ.users,password,usertype);
if(insertData) {
Toast.makeText(main2.this, "User has been
added.", Toast.LENGTH_SHORT).show();
usernameInside.setText("");
passwordInside.setText("");
}
} else {
Toast.makeText(main2.this, "User already exist.",
Toast.LENGTH_SHORT).show();
}
}
}
});
buttonView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String data = mynewdbAdapter.getData();
Toast.makeText(getApplicationContext(), data,
Toast.LENGTH_LONG).show();
});
buttonDelete.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Editdelete.setVisibility(View.VISIBLE);
buttonSubmitdelete.setVisibility(View.VISIBLE);
}
});
buttonUpdate.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
new1.setVisibility(View.VISIBLE);
new2.setVisibility(View.VISIBLE);
buttonSubmitUpdate.setVisibility(View.VISIBLE);
}
});
buttonSubmitUpdate.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
AJ.users = new1.getText().toString();
String userNew = new2.getText().toString();
if(AJ.users.isEmpty() || userNew.isEmpty())
{
Toast.makeText(main2.this, "Please fill in all the
required fields.", Toast.LENGTH_SHORT).show();
}
else
{
Boolean checkUser =
mynewdbAdapter.checkusername(AJ.users);
if(checkUser){
int b = mynewdbAdapter.updateUsername(AJ.users,
userNew);
Toast.makeText(main2.this, "User Updated.",
Toast.LENGTH_LONG).show();
} else {
Toast.makeText(main2.this, "User doesn't exist.",
Toast.LENGTH_SHORT).show();
new1.setText("");
new2.setText("");
}
}
}
});
logout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(main2.this,
main.class);
startActivity(intent);
}
});
buttonSubmitdelete.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
AJ.users = Editdelete.getText().toString();
if(AJ.users.isEmpty())
{
Toast.makeText(main2.this, "Please fill in all the
required fields..", Toast.LENGTH_SHORT).show();
}
else
{ Boolean checkUser =
mynewdbAdapter.checkusername(AJ.users);
if(checkUser) {
int a = mynewdbAdapter.delete(AJ.users);
Toast.makeText(main2.this, "User deleted.",
Toast.LENGTH_SHORT).show();
usernameInside.setText("");
}
else {
Toast.makeText(main2.this, "User doesn't exist.",
Toast.LENGTH_SHORT).show();
} usernameInside.setText("");
}
}
});
MAIN3:
package com.example.myapplication;
import androidx.appcompat.app.AppCompatActivity;
import android.app.AlertDialog;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Toast;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main3);
usernameInside = findViewById(R.id.usernameInside);
passwordInside = findViewById(R.id.passwordInside);
radios = findViewById(R.id.radios);
buttonAdd = findViewById(R.id.buttonAdd);
buttonView = findViewById(R.id.buttonView);
buttonDelete = findViewById(R.id.buttonDelete);
buttonUpdate = findViewById(R.id.buttonUpdate);
mynewdbAdapter = new myDbAdapter(this);
mynewdbAdapter.insertData("admin","admin","Super Admin");
new1 = findViewById(R.id.new1);
new2 = findViewById(R.id.new2);
buttonSubmitUpdate = findViewById(R.id.buttonSubmit);
logout = findViewById(R.id.logout);
buttonSubmitdelete = findViewById(R.id.buttonSubmitdelete);
Editdelete = findViewById(R.id.Editdelete);
buttonAdd.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
AJ.users = usernameInside.getText().toString();
String password = passwordInside.getText().toString();
String usertype =
((RadioButton)findViewById(radios.getCheckedRadioButtonId())).getText().toStr
ing();
Boolean checkUser = mynewdbAdapter.checkusername(AJ.users);
if ((AJ.users.isEmpty()) || (password.isEmpty())){
Toast.makeText(main3.this, "Please fill in all the
required fields.", Toast.LENGTH_SHORT).show();
} else{
if(!checkUser){//not true or not existing
Boolean insertData =
mynewdbAdapter.insertData(AJ.users,password,usertype);
if(insertData) {
Toast.makeText(main3.this, "User has been
added.", Toast.LENGTH_SHORT).show();
usernameInside.setText("");
passwordInside.setText("");
}
} else {
Toast.makeText(main3.this, "User already exist.",
Toast.LENGTH_SHORT).show();
}
}
}
});
buttonView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String data = mynewdbAdapter.getData();
Toast.makeText(getApplicationContext(), data,
Toast.LENGTH_LONG).show();
});
buttonDelete.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Editdelete.setVisibility(View.VISIBLE);
buttonSubmitdelete.setVisibility(View.VISIBLE);
}
});
buttonUpdate.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
new1.setVisibility(View.VISIBLE);
new2.setVisibility(View.VISIBLE);
buttonSubmitUpdate.setVisibility(View.VISIBLE);
}
});
buttonSubmitUpdate.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
AJ.users = new1.getText().toString();
String userNew = new2.getText().toString();
if(AJ.users.isEmpty() || userNew.isEmpty())
{
Toast.makeText(main3.this, "Please fill in all the
required fields.", Toast.LENGTH_SHORT).show();
}
else
{
Boolean checkUser =
mynewdbAdapter.checkusername(AJ.users);
if(checkUser){
int b = mynewdbAdapter.updateUsername(AJ.users,
userNew);
Toast.makeText(main3.this, "User Updated.",
Toast.LENGTH_LONG).show();
} else {
Toast.makeText(main3.this, "User doesn't exist.",
Toast.LENGTH_SHORT).show();
new1.setText("");
new2.setText("");
}
}
}
});
logout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(main3.this,
main.class);
startActivity(intent);
}
});
buttonSubmitdelete.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
AJ.users = Editdelete.getText().toString();
if(AJ.users.isEmpty())
{
Toast.makeText(main3.this, "Please fill in all the
required fields..", Toast.LENGTH_SHORT).show();
}
else
{ Boolean checkUser =
mynewdbAdapter.checkuserType(AJ.users);
if(checkUser) {
Toast.makeText(main3.this, "You can't delete Admin.",
Toast.LENGTH_SHORT).show();
usernameInside.setText("");
} else {
int a = mynewdbAdapter.delete(AJ.users);
Toast.makeText(main3.this, "User deleted.",
Toast.LENGTH_SHORT).show();
usernameInside.setText("");
}
}
});
}
MAIN4:
package com.example.myapplication;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main4);
view2.setText("Username:\n"+ AJ.users);
logout = findViewById(R.id.logout);
logout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(main4.this,
main.class);
startActivity(intent);
}
});
}
}
Message:
package com.example.myapplication;
import android.content.Context;
import android.widget.Toast;
}
}
myDbAdapter:
package com.example.myapplication;
import android.annotation.SuppressLint;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
myDbHelper myhelper;
public myDbAdapter(Context context)
{
myhelper = new myDbHelper(context);
}
db.execSQL(CREATE_TABLE);
} catch (Exception e) {
Message.message(context,""+e);
}
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int
newVersion) {
db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME);
onCreate(db);
}
}
SQLiteDatabase db = myhelper.getWritableDatabase();
String[] columns =
{myDbHelper.USERID,myDbHelper.USERNAME,myDbHelper.USERPASSWORD,myDbHelper.ACC
OUNTTYPE};
Cursor cursor
=db.query(myDbHelper.TABLE_NAME,columns,null,null,null,null,null);
StringBuffer buffer= new StringBuffer();
while (cursor.moveToNext()) {
@SuppressLint("Range") int cid
=cursor.getInt(cursor.getColumnIndex(myDbHelper.USERID));
@SuppressLint("Range") String username
=cursor.getString(cursor.getColumnIndex(myDbHelper.USERNAME));
@SuppressLint("Range") String password
=cursor.getString(cursor.getColumnIndex(myDbHelper.USERPASSWORD));
@SuppressLint("Range") String usertype
=cursor.getString(cursor.getColumnIndex(myDbHelper.ACCOUNTTYPE));
buffer.append(cid+ " " + username + " " + password +" " +
usertype +" \n");
}
return buffer.toString();
}
public Boolean checkusername(String users) {
SQLiteDatabase MyDB = myhelper.getWritableDatabase();
Cursor cursor = MyDB.rawQuery("Select * from LoginSystem_tb where
USERNAME = ?", new String[]{AJ.users});
if (cursor.getCount() > 0)
return true;
else
return false;
}
public Boolean checkusernamepassword(String username, String password) {
SQLiteDatabase MyDB = myhelper.getWritableDatabase();
Cursor cursor = MyDB.rawQuery("Select * from LoginSystem_tb where
USERNAME = ? and PASSWORD = ?", new String[]{username,password});
if (cursor.getCount() > 0)
return true;
else
return false;
}
public Boolean checkuserType(String username) {
String args = "Admin";
SQLiteDatabase MyDB = myhelper.getWritableDatabase();
Cursor cursor = MyDB.rawQuery("Select * from LoginSystem_tb where
USERNAME = ? and USERTYPE = ?", new String[]{username,args});
if (cursor.getCount() > 0)
return true;
else
return false;
}
public int updateUsername(String oldName , String newName)
{
SQLiteDatabase db = myhelper.getWritableDatabase();
ContentValues contentValues = new ContentValues();
contentValues.put(myDbHelper.USERNAME,newName);
String[] whereArgs= {AJ.users};
int count =db.update(myDbHelper.TABLE_NAME,contentValues,
myDbHelper.USERNAME+" = ?",whereArgs );
return count;
}
public int delete(String username)
{
SQLiteDatabase db = myhelper.getWritableDatabase();
String[] whereArgs ={AJ.users};
AJ:
package com.example.myapplication;
public class AJ {
public static String users;
}
XML CODES(MAIN):
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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_height="match_parent"
tools:context=".main">
<TextView
android:id="@+id/textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="100dp"
android:layout_marginBottom="70dp"
android:text="Final Project
Login System"
android:textSize="40dp"
android:gravity="center"
/>
<EditText
android:id="@+id/usernameOutside"
android:layout_width="287dp"
android:layout_height="60dp"
android:layout_below="@id/textview"
android:layout_centerHorizontal="true"
android:hint="Username"
android:inputType="text"
android:textAlignment="center"
android:textStyle="italic"
/>
<EditText
android:layout_marginTop="10dp"
android:id="@+id/passwordOutside"
android:layout_width="287dp"
android:layout_height="60dp"
android:inputType="textPassword"
android:layout_below="@id/usernameOutside"
android:layout_centerHorizontal="true"
android:hint="Password"
android:textAlignment="center"
android:textStyle="italic"
/>
<Button
android:id="@+id/buttonLogin"
android:layout_width="131dp"
android:layout_height="wrap_content"
android:layout_below="@id/passwordOutside"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:text="Login"
android:textColor="@color/black" />
</RelativeLayout>
MAIN2:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView 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_height="match_parent"
tools:context=".main2"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<EditText
android:id="@+id/usernameInside"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="30dp"
android:hint="Username"
android:inputType="text"
android:textAlignment="center"
android:textColor="@color/black"
android:textStyle="italic" />
<EditText
android:id="@+id/passwordInside"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/usernameInside"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:hint="Password"
android:inputType="textPassword"
android:textAlignment="center"
android:textColor="@color/black"
android:textStyle="italic" />
<RadioGroup
android:layout_marginTop="10dp"
android:id="@+id/radios"
android:layout_width="189dp"
android:layout_height="60dp"
android:layout_below="@id/passwordInside"
android:layout_centerHorizontal="true"
android:orientation="horizontal"
android:textColor="@color/black"
>
<RadioButton
android:id="@+id/radio1"
android:layout_width="95dp"
android:layout_height="match_parent"
android:text="Admin"
android:textAlignment="center"
android:textColor="@color/black"
/>
<RadioButton
android:id="@+id/radio2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAlignment="center"
android:checked="true"
android:textColor="@color/black"
android:text="User" />
</RadioGroup>
<Button
android:id="@+id/buttonAdd"
android:layout_width="104dp"
android:layout_height="38dp"
android:layout_below="@id/radios"
android:layout_alignParentStart="true"
android:layout_marginStart="63dp"
android:layout_marginTop="7dp"
android:text="add"
android:textColor="@color/black" />
<Button
android:id="@+id/buttonDelete"
android:layout_width="104dp"
android:layout_height="38dp"
android:layout_marginLeft="300dp"
android:layout_marginTop="600dp"
android:text="delete"
android:visibility="gone"
android:textColor="@color/black"
/>
<EditText
android:id="@+id/Editdelete"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:layout_marginTop="600dp"
android:hint="Username"
android:textAlignment="center"
android:textColor="@color/black"
android:textStyle="italic" />
<Button
android:id="@+id/buttonSubmitdelete"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_marginLeft="280dp"
android:layout_marginTop="595dp"
android:text="Delete"
android:textColor="@color/black"
/>
<Button
android:id="@+id/buttonUpdate"
android:layout_width="104dp"
android:layout_height="38dp"
android:layout_marginLeft="180dp"
android:layout_marginTop="330dp"
android:text="update"
android:visibility="gone"
android:textColor="@color/black"
/>
<Button
android:id="@+id/buttonView"
android:layout_width="150dp"
android:layout_height="38dp"
android:layout_below="@id/radios"
android:layout_alignParentEnd="true"
android:layout_marginTop="9dp"
android:layout_marginEnd="61dp"
android:text="View Data"
android:textColor="@color/black" />
<EditText
android:id="@+id/new1"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_marginTop="300dp"
android:hint="Old username"
android:textAlignment="center"
android:textColor="@color/black"
android:textStyle="italic" />
<EditText
android:id="@+id/new2"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_marginTop="350dp"
android:hint="New Username"
android:textAlignment="center"
android:textColor="@color/black"
android:textStyle="italic" />
<Button
android:id="@+id/buttonSubmit"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_marginLeft="180dp"
android:layout_marginTop="330dp"
android:text="Update"
android:textColor="@color/black" />
<Button
android:id="@+id/logout"
android:layout_width="152dp"
android:layout_height="47dp"
android:layout_below="@id/new2"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:text="Logout"
android:visibility="gone"
android:textColor="@color/black" />
</RelativeLayout>
</ScrollView>
MAIN3:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView 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_height="match_parent"
tools:context=".main3"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<EditText
android:id="@+id/usernameInside"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="30dp"
android:hint="Username"
android:inputType="text"
android:textAlignment="center"
android:textColor="@color/black"
android:textStyle="italic" />
<EditText
android:id="@+id/passwordInside"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/usernameInside"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:hint="Password"
android:inputType="textPassword"
android:textAlignment="center"
android:textColor="@color/black"
android:textStyle="italic" />
<RadioGroup
android:layout_marginTop="10dp"
android:id="@+id/radios"
android:layout_width="189dp"
android:layout_height="60dp"
android:layout_below="@id/passwordInside"
android:layout_centerHorizontal="true"
android:orientation="horizontal"
android:textColor="@color/black"
>
<RadioButton
android:id="@+id/radio1"
android:layout_width="95dp"
android:layout_height="match_parent"
android:text="Admin"
android:visibility="gone"
android:textAlignment="center"
android:textColor="@color/black"
/>
<RadioButton
android:id="@+id/radio2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAlignment="center"
android:checked="true"
android:textColor="@color/black"
android:text="admin" />
</RadioGroup>
<Button
android:id="@+id/buttonAdd"
android:layout_width="104dp"
android:layout_height="38dp"
android:layout_below="@id/radios"
android:layout_alignParentStart="true"
android:layout_marginStart="63dp"
android:layout_marginTop="7dp"
android:text="add"
android:textColor="@color/black" />
<Button
android:id="@+id/buttonDelete"
android:layout_width="104dp"
android:layout_height="38dp"
android:layout_marginLeft="300dp"
android:layout_marginTop="600dp"
android:text="delete"
android:visibility="gone"
android:textColor="@color/black"
/>
<EditText
android:id="@+id/Editdelete"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:layout_marginTop="600dp"
android:hint="Username"
android:textAlignment="center"
android:textColor="@color/black"
android:textStyle="italic" />
<Button
android:id="@+id/buttonSubmitdelete"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_marginLeft="280dp"
android:layout_marginTop="595dp"
android:text="Delete"
android:textColor="@color/black"
/>
<Button
android:id="@+id/buttonUpdate"
android:layout_width="104dp"
android:layout_height="38dp"
android:layout_marginLeft="180dp"
android:layout_marginTop="330dp"
android:text="update"
android:visibility="gone"
android:textColor="@color/black"
/>
<Button
android:id="@+id/buttonView"
android:layout_width="150dp"
android:layout_height="38dp"
android:layout_below="@id/radios"
android:layout_alignParentEnd="true"
android:layout_marginTop="9dp"
android:layout_marginEnd="61dp"
android:text="View Data"
android:textColor="@color/black" />
<EditText
android:id="@+id/new1"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_marginTop="300dp"
android:hint="Old username"
android:textAlignment="center"
android:textColor="@color/black"
android:textStyle="italic" />
<EditText
android:id="@+id/new2"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_marginTop="350dp"
android:hint="New Username"
android:textAlignment="center"
android:textColor="@color/black"
android:textStyle="italic" />
<Button
android:id="@+id/buttonSubmit"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_marginLeft="180dp"
android:layout_marginTop="330dp"
android:text="Update"
android:textColor="@color/black" />
<Button
android:id="@+id/logout"
android:layout_width="152dp"
android:layout_height="47dp"
android:layout_below="@id/new2"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:text="Logout"
android:visibility="gone"
android:textColor="@color/black" />
</RelativeLayout>
</ScrollView>
MAIN4:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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_height="match_parent"
tools:context=".main4">
<TextView
android:id="@+id/view1"
android:layout_width="297dp"
android:layout_height="99dp"
android:layout_centerHorizontal="true"
android:layout_marginTop="50dp"
android:text="Welcome User!"
android:textAlignment="center"
android:textSize="35dp"
android:textStyle="bold" />
<TextView
android:id="@+id/view2"
android:layout_width="wrap_content"
android:layout_height="66dp"
android:layout_centerHorizontal="true"
android:layout_marginTop="100dp"
android:textAlignment="center"
android:textSize="28dp"
android:layout_below="@id/view1"
android:textColor="@color/black"
/>
<Button
android:id="@+id/logout"
android:layout_width="152dp"
android:layout_height="47dp"
android:layout_below="@id/view2"
android:layout_centerHorizontal="true"
android:text="SignOut"
android:textAlignment="center"
android:textColor="@color/black" />
</RelativeLayout>
OUTPUTS:
Input user , user as user and pass
Adding admin1 as admin
User and admin toast
Deleted newUser
Logged in as admin
Admin can’t be deleted