EditText box entered value is accessible by getText() function. This function is used with combination of EditText box id assign variable. After get EditText box value i am showing this selected value on Toast message through button click event.
Code for MainActivity.java file .
package com.example.getenterededittextboxvalue;
import android.app.Activity;
import android.os.Bundle;
import android.text.Editable;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class MainActivity extends Activity {
EditText GetvalueBox;
Button AccessButton;
Editable HoldValue;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
GetvalueBox = (EditText)findViewById(R.id.editText1);
AccessButton = (Button)findViewById(R.id.access_value);
AccessButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
HoldValue = GetvalueBox.getText();
Toast.makeText(MainActivity.this, HoldValue, Toast.LENGTH_SHORT).show();
}
});
}
}
Code for activity_main.xml file .
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.getenterededittextboxvalue.MainActivity" >
<EditText
android:id="@+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="47dp"
android:ems="10"
android:inputType="textPersonName" >
</EditText>
<Button
android:id="@+id/access_value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@+id/editText1"
android:layout_below="@+id/editText1"
android:layout_marginTop="45dp"
android:text="Access EditText Box value" />
</RelativeLayout>
Haloo pak^^
ReplyDeleteKami dari SENTANAPOKER ingin menawarkan pak^^
Untuk saat ini kami menerima Deposit Melalui Pulsa ya pak.
*untuk minimal deposit 10ribu
*untuk minimal Withdraw 25ribu
*untuk deposit pulsa kami menerima provider
-XL
-Telkomsel
untuk bonus yang kami miliki kami memiliki
*bonus cashback 0,5%
*bunus refferal 20%
*bonus gebiar bulanan (N-max,samsung Note 10+,Iphone xr 64G,camera go pro 7hero,Apple airpods 2 ,dan freechips)
Daftar Langsung Di:
SENTANAPOKER
Kontak Kami;
WA : +855 9647 76509
Line : SentanaPoker
Wechat : SentanaPokerLivechat Sentanapoker
Proses deposit dan withdraw tercepat bisa anda rasakan jika bermain di Sentanapoker. So… ? tunggu apa lagi ? Mari bergabung dengan kami. Pelayanan CS yang ramah dan Proffesional dan pastinya sangat aman juga bisa anda dapatkan di Sentanapoker.