







Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
The XML and Java code for the login and user profile pages of an Android mobile application developed in the lab URK18CS144 of the 18CS2056 course. The code includes the layout design of the login page with EditText fields for username and password, a Button for login, and a TextView for the link to the registration page. The user profile page consists of TextViews for displaying the user's email, phone number, date of birth, and username, and a Button for updating the password.
Typology: Lab Reports
1 / 13
This page cannot be seen from the preview
Don't miss anything!
activity_main.xml
app:layout_constraintTop_toTopOf="parent" />
package com.example.exp5; 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.TextView; import android.widget.Toast; public class MainActivity extends AppCompatActivity { EditText user, password; Button loginbtn; TextView textlink; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout. activity_main ); user = findViewById(R.id. username ); password = findViewById(R.id. password ); loginbtn = findViewById(R.id. buttonlogin ); textlink = findViewById(R.id. textlink ); final DBHelper DB= new DBHelper(this, "USER", null, 1 ); textlink.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { newuseractivity(); } }); loginbtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { String username=user.getText().toString();
String passwordcheck=password.getText().toString(); Boolean s=DB.checkUser(username, passwordcheck); if(s==true) {Toast. makeText (MainActivity.this, "Log in successful", Toast. LENGTH_LONG ).show(); userprofileactivity(); } else Toast. makeText (MainActivity.this,"invalid Credentials",Toast. LENGTH_LONG ).show(); } }); } public void newuseractivity() { Intent intent = new Intent(MainActivity.this, NewUser.class); startActivity(intent); } public void userprofileactivity() { Intent intent = new Intent(MainActivity.this,UserProfile2.class); intent.putExtra("Username", user.getText().toString()); startActivity(intent); } } activity_user_profile2.xml
android:layout_height="wrap_content" android:layout_marginStart="52dp" android:layout_marginTop="1dp" android:text="Phone" android:textColor="@color/white" app:layout_constraintStart_toStartOf="@+id/twoupdatebuttonuser" app:layout_constraintTop_toBottomOf="@+id/twoprofile_t2" />
app:layout_constraintBottom_toTopOf="@+id/twoprofile_t1" app:layout_constraintStart_toStartOf="@+id/twoprofile_t1" />
username.setText(userintent); Email.setText(db.particularUser(userintent, 2 )); dob.setText(db.particularUser(userintent, 3 )); phone.setText(db.particularUser(userintent, 4 )); updatebutton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { startActivity(updateIntent); } }); } }