Create an input method - Android Developers
<?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"
android:background="#F8C323"
tools:context=".UserInput">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardElevation="10dp"
app:cardCornerRadius="20dp"
app:cardBackgroundColor="@color/white"
app:cardUseCompatPadding="true"
>
<TextView
android:layout_marginTop="10dp"
android:layout_margin="5dp"
android:textSize="25sp"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textColorLink="@color/black"
android:text="User Imput "/>
</androidx.cardview.widget.CardView>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardElevation="10dp"
app:cardCornerRadius="20dp"
app:cardBackgroundColor="@color/white"
app:cardUseCompatPadding="true"
>
<EditText
android:id="@+id/ImputText"
android:layout_width="match_parent"
android:layout_height="80dp"
android:textSize="25sp"
android:gravity="center"
/>
</androidx.cardview.widget.CardView>
</LinearLayout>
<Button
app:cardCornerRadius="20dp"
android:id="@+id/ClickKorun"
android:layout_marginTop="10dp"
android:layout_margin="5dp"
android:textSize="25sp"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textColorLink="@color/black"
android:text="Click Korun "
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardElevation="10dp"
app:cardCornerRadius="20dp"
app:cardBackgroundColor="@color/white"
app:cardUseCompatPadding="true"
>
<TextView
android:id="@+id/ResultShow"
android:layout_width="match_parent"
android:layout_height="80dp"
android:textSize="25sp"
android:gravity="center"
/>
</androidx.cardview.widget.CardView>
</LinearLayout>
</LinearLayout>
<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"
android:background="#F8C323"
tools:context=".UserInput">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardElevation="10dp"
app:cardCornerRadius="20dp"
app:cardBackgroundColor="@color/white"
app:cardUseCompatPadding="true"
>
<TextView
android:layout_marginTop="10dp"
android:layout_margin="5dp"
android:textSize="25sp"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textColorLink="@color/black"
android:text="User Imput "/>
</androidx.cardview.widget.CardView>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardElevation="10dp"
app:cardCornerRadius="20dp"
app:cardBackgroundColor="@color/white"
app:cardUseCompatPadding="true"
>
<EditText
android:id="@+id/ImputText"
android:layout_width="match_parent"
android:layout_height="80dp"
android:textSize="25sp"
android:gravity="center"
/>
</androidx.cardview.widget.CardView>
</LinearLayout>
<Button
app:cardCornerRadius="20dp"
android:id="@+id/ClickKorun"
android:layout_marginTop="10dp"
android:layout_margin="5dp"
android:textSize="25sp"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textColorLink="@color/black"
android:text="Click Korun "
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardElevation="10dp"
app:cardCornerRadius="20dp"
app:cardBackgroundColor="@color/white"
app:cardUseCompatPadding="true"
>
<TextView
android:id="@+id/ResultShow"
android:layout_width="match_parent"
android:layout_height="80dp"
android:textSize="25sp"
android:gravity="center"
/>
</androidx.cardview.widget.CardView>
</LinearLayout>
</LinearLayout>
Java
package com.shamimit.ourmusic;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class UserInput extends AppCompatActivity {
EditText ImputText;
TextView ResultShow;
Button ClickKorun;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_user_input);
ImputText=findViewById(R.id.ImputText);
ResultShow=findViewById(R.id.ResultShow);
ClickKorun=findViewById(R.id.ClickKorun);
ClickKorun.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String MyImpurttext=ImputText.getText().toString();
ResultShow.setText("Apnr Result"+MyImpurttext);
}
});
}
}
Tags:
App-Development