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

Package Com - Example.a02

This document is a Java code for an Android application that defines a MainActivity class. It initializes UI elements including an EditText for user input and a TextView for displaying text. A button click listener is set up to display the user's input in the TextView when the button is clicked.

Uploaded by

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

Package Com - Example.a02

This document is a Java code for an Android application that defines a MainActivity class. It initializes UI elements including an EditText for user input and a TextView for displaying text. A button click listener is set up to display the user's input in the TextView when the button is clicked.

Uploaded by

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

package com.example.

a02;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {


private EditText editTextUserInput;
private TextView textViewDisplay;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

// Initialize UI elements
editTextUserInput = findViewById(R.id.editTextUserInput);
Button buttonShowText = findViewById(R.id.buttonShowText);
textViewDisplay = findViewById(R.id.textViewDisplay);

// Button click listener


buttonShowText.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// Get text from EditText
String userInput = editTextUserInput.getText().toString();

// Set text to TextView


textViewDisplay.setText(userInput);
}
});
}
}

You might also like