P13 code
P13 code
P13 code
package com.example.prac13;
import android.app.Activity;
import android.text.InputFilter.LengthFilter
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
@SuppressWarnings("ALL")
public abstract class MainActivity<method> extends Activity implements
OnClickListener, P13 {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button b1;
b1 = (Button) findViewById(R.id.button);
b1.setOnClickListener(this);
}
@Override
public boolean OnCreateOptionsMenu(Menu menu){
//Inflate the menu;this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main,menu);
return true;
}
@Override
public void OnClick() {
OnClick();
}
@Override
public void onClick(View arg)
{
/* TODO Auto-generated */
EditText t1= (EditText)findViewById(R.id.editText1);
String s1=t1.getText().toString();
Toast.makeText(this,s1,Toast.LENGTH_LONG).show();
}
}
Xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
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:id="@+id/relativeLayout"
Android:layout_width="match_parent"
Android:layout_height="match_parent"
tools:ignore="MissingPrefix">
<TextView
Android:id="@+id/textView2"
Android:layout_width="wrap_content"
Android:layout_height="wrap_content"
Android:layout_marginStart="48dp"
Android:layout_marginTop="72dp"
Android:text="Name"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="HardcodedText" />
<EditText
Android:id="@+id/editTextTextPersonName"
Android:layout_width="wrap_content"
Android:layout_height="48dp"
Android:layout_marginStart="168dp"
Android:layout_marginTop="56dp"
Android:ems="10"
Android:inputType="textPersonName"
Android:text="Enter Your Name"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="Autofill,HardcodedText,LabelFor" />
<Button
Android:id="@+id/button"
Android:layout_width="wrap_content"
Android:layout_height="wrap_content"
Android:layout_marginStart="160dp"
Android:layout_marginTop="120dp"
Android:text="Submit"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="HardcodedText,MissingConstraints" />
</androidx.constraintlayout.widget.ConstraintLayout>