0% found this document useful (0 votes)
4 views1 page

General Code XML Layout

The document contains an XML layout for an Android application with a vertical LinearLayout that includes an EditText for name input, a Button to submit the input, and a TextView to display a welcome message. The Java code defines a MainActivity that initializes these UI components and sets an OnClickListener on the button to update the TextView with a welcome message using the input from the EditText. This provides a simple user interface for greeting users by name.

Uploaded by

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

General Code XML Layout

The document contains an XML layout for an Android application with a vertical LinearLayout that includes an EditText for name input, a Button to submit the input, and a TextView to display a welcome message. The Java code defines a MainActivity that initializes these UI components and sets an OnClickListener on the button to update the TextView with a welcome message using the input from the EditText. This provides a simple user interface for greeting users by name.

Uploaded by

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

General Code XML Layout (activity_main.

xml)
<LinearLayout
xmlns:android="[Link]
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<EditText
android:id="@+id/et1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter Name"/>

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

<TextView
android:id="@+id/tv1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>

Java Code ([Link])


import [Link];
import [Link].*;

import [Link];

public class MainActivity extends AppCompatActivity {

EditText et1;
Button btn1;
TextView tv1;

@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);

et1 = findViewById([Link].et1);
btn1 = findViewById([Link].btn1);
tv1 = findViewById([Link].tv1);

[Link](v -> {
String name = [Link]().toString();
[Link]("Welcome " + name);
});
}
}

You might also like