0% found this document useful (0 votes)
17 views5 pages

Practical 7 Code

The document contains two XML layouts and corresponding Java code for Android applications. The first layout is for a user login interface with fields for username and password, while the second layout collects personal information including name, date of birth, and blood group. Both applications feature a submit button that displays the entered information in a TextView upon clicking.

Uploaded by

anujkothawale93
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views5 pages

Practical 7 Code

The document contains two XML layouts and corresponding Java code for Android applications. The first layout is for a user login interface with fields for username and password, while the second layout collects personal information including name, date of birth, and blood group. Both applications feature a submit button that displays the entered information in a TextView upon clicking.

Uploaded by

anujkothawale93
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

1:-

<?xml version="1.0" encoding="utf-8" ?>


<LinearLayout
xmlns:android="[Link]
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_margin="10sp">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/Username"/>

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/Username"
android:hint="@string/Username"/>

</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/Password"/>

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/Password"
android:hint="@string/Password"
android:inputType="textPassword"/>

</LinearLayout>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/Submit"
android:id="@+id/Submit"
android:layout_gravity="center"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/Display"
android:text=""
android:layout_gravity="center"
android:textStyle="bold"
android:textSize="30sp"
android:textColor="@color/black"/>

</LinearLayout>

package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];

public class MainActivity extends Activity {


@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
EditText username=findViewById([Link]);
EditText password=findViewById([Link]);
Button submit=findViewById([Link]);
TextView display=findViewById([Link]);

[Link](v->{
String Username=[Link]().toString();
String Password=[Link]().toString();
[Link](getString([Link],Username,Password));
}
);
}
}

2:-
<?xml version="1.0" encoding="utf-8" ?>
<LinearLayout
xmlns:android="[Link]
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_margin="10sp">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/Name"/>

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/Name"
android:hint="@string/Name"
android:inputType="textPersonName"/>

</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/DOB"/>

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/DOB"
android:hint="@string/DOB"
android:inputType="date"/>

</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/BloodGroup"/>

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/BloodGroup"
android:hint="@string/BloodGroup"/>

</LinearLayout>

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/Submit"
android:id="@+id/Submit"
android:layout_gravity="center"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/Display"
android:text=""
android:layout_gravity="center"
android:textStyle="bold"
android:textSize="30sp"
android:textColor="@color/black"/>

</LinearLayout>

package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];

public class MainActivity extends Activity {


@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
EditText name=findViewById([Link]);
EditText dob=findViewById([Link]);
EditText bloodGroup=findViewById([Link]);
Button submit=findViewById([Link]);
TextView display=findViewById([Link]);

[Link](v->{
String Name=[Link]().toString();
String Dob=[Link]().toString();
String BloodGroup=[Link]().toString();
[Link](getString([Link],Name,Dob,BloodGroup));
}
);

}
}

You might also like