0% found this document useful (0 votes)
6 views

Android

The document contains an XML layout for an Android application with a LinearLayout that includes a TextView, two EditTexts, and a Button. The Java code defines a MainActivity that initializes these UI components and sets an OnClickListener for the Button to increment the value entered in the first EditText and display it in the second EditText. The code also includes a nested class for handling click events, although it is not utilized in the current implementation.

Uploaded by

rocksdevesh
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Android

The document contains an XML layout for an Android application with a LinearLayout that includes a TextView, two EditTexts, and a Button. The Java code defines a MainActivity that initializes these UI components and sets an OnClickListener for the Button to increment the value entered in the first EditText and display it in the second EditText. The code also includes a nested class for handling click events, although it is not utilized in the current implementation.

Uploaded by

rocksdevesh
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

xml

<?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"
tools:context="com.learningandi.mypro1.MainActivity">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<Button
android:id="@+id/b1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button"
tools:layout_editor_absoluteX="147dp"
tools:layout_editor_absoluteY="367dp" />

<EditText
android:id="@+id/et1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:text="Name"
tools:layout_editor_absoluteX="74dp"
tools:layout_editor_absoluteY="95dp" />

<EditText
android:id="@+id/et2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:text="Name"
tools:layout_editor_absoluteX="74dp"
tools:layout_editor_absoluteY="179dp" />

</LinearLayout>

java

package com.learningandi.mypro1;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class MainActivity extends AppCompatActivity {


private EditText et1,et2;
private Button b1;

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

//page work
et1 = (EditText) findViewById(R.id.et1);
et2 = (EditText) findViewById(R.id.et2);
b1 =(Button) findViewById(R.id.b1);

b1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int a = Integer.parseInt(et1.getText().toString());

a++;

et2.setText(""+a);
}
});

class MyclickListner implements View.OnClickListener{


@Override
public void onClick(View v) {
int a = Integer.parseInt(et1.getText().toString());
a++;
}
}

You might also like