Java File

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

Xml File: Java File:

<? xml version="1.0" encoding="utf-8"?> package com.example.myapplication;


<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android" import androidx.appcompat.app.AppCompatActivity;
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" import android.annotation.SuppressLint;
android:layout_width="match_parent" import android.os.Bundle;
android:layout_height="match_parent" import android.view.View;
android:orientation="vertical" import android.widget.Button;
tools:context=".MainActivity"> import android.widget.EditText;
<TextView import android.widget.TextView;
android:layout_width="wrap_content"
android:layout_height="wrap_content" public class MainActivity extends AppCompatActivity {
android:text="Name:"
/> @Override
<EditText protected void onCreate(Bundle savedInstanceState) {
android:layout_width="wrap_content" super.onCreate(savedInstanceState);
android:layout_height="wrap_content" setContentView(R.layout.activity_main);
android:id="@+id/nm" final EditText ed1=(EditText) findViewById(R.id.nm);
/> final EditText ed2=(EditText) findViewById(R.id.ro);
final EditText ed3=(EditText) findViewById(R.id.pe);
<TextView final TextView te1=(TextView) findViewById(R.id.di);
android:layout_width="wrap_content" final Button bt=(Button) findViewById(R.id.btn);
android:layout_height="wrap_content" bt.setOnClickListener(new View.OnClickListener()
android:text="RollNO:" {
/> public void onClick(View view)
<EditText {
android:layout_width="wrap_content" String name=ed1.getText().toString();
android:layout_height="wrap_content" String roll= String.valueOf(ed2.getText());
android:id="@+id/ro"/> String percent= String.valueOf(ed3.getText());
te1.setText("Name:"+name+"\n Roll No:"+roll+"\
<TextView nPercentage:"+percent);
android:layout_width="wrap_content" }
android:layout_height="wrap_content" });
android:text="Percentage:" }
/> }
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/pe"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Submit"
android:id="@+id/btn"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/di"/>
</LinearLayout>

7_2
7_2
7_1

Xml File: Output:


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
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"
android:orientation="vertical"
tools:context=".MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Username:"/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Password:"/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Submit"/>
</LinearLayout>

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy