EditText with delete option - android

Hi please lead me some examples which demonstrate how to create editText with "delete" button , when click on the delete option it will remove the created editText . Thanks in advance ...
code for creating textEdit dynamically..
LinearLayout rAlign = (LinearLayout)findViewById(R.id.lId);
EditText newPass = new EditText(getApplicationContext());
allEds.add(newPass);
newPass.setHint("Name of Label");
newPass.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
newPass.setWidth(318);
newPass.setTextColor(Color.parseColor("#333333"));
newPass.setId(MY_BUTTON);
//newPass.
//newPass.setOnClickListener(this);
rAlign.addView(newPass);
MY_BUTTON ++;
addSpinner(); //Function for adding spinner

The layout could be something like this:
<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" >
<EditText
android:id="#+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginTop="50dp"
android:ems="10" >
<requestFocus />
</EditText>
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/editText1"
android:layout_alignBottom="#+id/editText1"
android:layout_toRightOf="#+id/editText1"
android:text="Button" />
And the Java could be like this:
public class MainActivity extends Activity implements OnClickListener {
TextView tv;
Button btn;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btn = (Button) findViewById(R.id.button1);
tv = (TextView) findViewById(R.id.editText1);
btn.setOnClickListener(this);
}
#Override
public void onClick(View v) {
tv.setVisibility(View.GONE);
}
}

Related

How can I switch edittext like Google Translate when I press switch button?

is it possible that to do it with animation?
I found on google textview switcher but I want to switch edittext
I want to do like this:
thanks in advance.
May be this can help you,..
activity_main.xml :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/linMain"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:weightSum="2"
tools:context="com.app.edittextswitch.MainActivity">
<EditText
android:id="#+id/edit1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#android:drawable/editbox_background_normal" />
<ImageView
android:id="#+id/imgView"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:background="#drawable/arrow" />
<EditText
android:id="#+id/edit2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#android:drawable/editbox_background_normal" />
</LinearLayout>
MainActivity.java :
public class MainActivity extends AppCompatActivity {
EditText edit1, edit2;
ImageView imgView;
Animation slide_in_left, slide_out_right;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
imgView = (ImageView) findViewById(R.id.imgView);
edit1 = (EditText) findViewById(R.id.edit1);
edit2 = (EditText) findViewById(R.id.edit2);
slide_in_left = AnimationUtils.loadAnimation(this,
android.R.anim.slide_in_left);
slide_out_right = AnimationUtils.loadAnimation(this,
android.R.anim.slide_out_right);
imgView.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
String text1 = edit1.getText().toString();
String text2 = edit2.getText().toString();
edit1.setText(text2);
edit2.setText(text1);
edit1.startAnimation(slide_out_right);
edit2.startAnimation(slide_out_right);
}
});
}
}

Unsuccessful opening second activity

So I am trying to open a second activity from the first activity from a click of a button. The app loads up but then when I try to press the button to go to the next activity nothing happens. Here is my main.xml, mainactivity.java, androidmanifest.xml, shopactivity.java and shop.xml, respectively. Any help is greatly appreciated.
main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:text="#string/counter"
android:textColor="#000000"/>
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/textView1"
android:text="#string/gems"
android:textColor="#000000"/>
<EditText
android:id="#+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#+id/textView1"
android:layout_alignBaseline="#+id/textView1"
android:clickable="false"
android:cursorVisible="false"
android:focusable="false"
android:focusableInTouchMode="false"
android:textColor="#000000"/>
<EditText
android:id="#+id/editText2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#+id/textView2"
android:layout_alignBaseline="#+id/textView2"
android:clickable="false"
android:cursorVisible="false"
android:focusable="false"
android:focusableInTouchMode="false"
android:textColor="#000000"/>
<Button
android:id="#+id/button1"
android:layout_width="match_parent"
android:layout_height="310dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:background="#000000"
android:text="#string/button"
android:textColor="#ffffff"/>
<Button
android:id="#+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/button1"
android:background="#ffffff"
android:text="#string/button2"
android:textColor="#000000"
android:onClick="onClickShop"/>
<Button
android:id="#+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/button1"
android:layout_alignParentRight="true"
android:background="#ffffff"
android:text="#string/button3"
android:textColor="#000000"/>
<Button
android:id="#+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/button1"
android:layout_centerHorizontal="true"
android:layout_toRightOf="#+id/button2"
android:layout_toLeftOf="#+id/button3"
android:background="#ffffff"
android:text="#string/button4"
android:textColor="#000000"/>
</RelativeLayout>
MainActivity.java
public class MainActivity extends Activity implements OnClickListener{
TextView textView1;
TextView textView2;
EditText editText1;
EditText editText2;
Button button1;
Button button2;
Button button3;
Button button4;
int counter = 0;
int gems = 0;
#Override
public void onCreate(Bundle savedInstanceState)
{super.onCreate(savedInstanceState);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
setContentView(R.layout.main);
textView1 = (TextView)findViewById(R.id.textView1);
textView2 = (TextView)findViewById(R.id.textView2);
editText1 = (EditText)findViewById(R.id.editText1);
editText2 = (EditText)findViewById(R.id.editText2);
button1 = (Button)findViewById(R.id.button1);
button2 = (Button)findViewById(R.id.button2);
button3 = (Button)findViewById(R.id.button3);
button4 = (Button)findViewById(R.id.button4);
button1.setOnClickListener(this);
button2.setOnClickListener(this);
button3.setOnClickListener(this);
button4.setOnClickListener(this);}
#Override
protected void onStop()
{super.onStop();
SharedPreferences prefs = this.getSharedPreferences("com.bugagullgames.clicker", Context.MODE_PRIVATE);
SharedPreferences.Editor editor = prefs.edit(); editor.putInt("key", counter); editor.commit();}
#Override
protected void onStart()
{super.onStart(); SharedPreferences prefs = this.getSharedPreferences("com.bugagullgames.clicker", Context.MODE_PRIVATE);
int defaultValue = 0;
counter = prefs.getInt("key", defaultValue);
editText1.setText(Integer.toString(counter));}
#Override
public void onClick(View v)
{if (v == button1)
{counter++; editText1.setText(Integer.toString(counter));}}
public void onClickShop(View v)
{if (v == button2)
{
Intent intent = new Intent(MainActivity.this, ShopActivity.class);
startActivity(intent);
}}}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.bugagullgames.clicker" >
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme">
<activity
android:name=".MainActivity"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".ShopActivity"
android:label="#string/app_name">
</activity>
</application>
</manifest>
public class ShopActivity extends MainActivity
{
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.shop);
}}
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<TextView
android:text="Welcome to the shop"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"/>
</RelativeLayout>
You are overriding the button2 onclick listener. Remove this line of code:
button2 = (Button)findViewById(R.id.button2);
And the xml onclick property that you configured android:onClick="onClickShop" should work.
hello #Bugagull define your "ShopActivity.class" in your menifest.
<activity
android:name=".ShopActivity"
android:label="#string/app_name">
</activity>
and replace this .
public class ShopActivity extends Activity
{
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.shop);
}
}
If you want use a xml method .
your declaration method must be like it.
public void methodname(View v)
it's important to put this argument.
overriding the button2 onclick listener. Programmatic this show;
button2.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
onClickShop(v);
}
});
Replace {if (v == button2)for {if (v == button2.getView())or try to find by ID.
I recommend use:
button2.setOnclickListener(new OnClickListener {
// TO DO
})

Adding a Textview to a Relative Layout in Android Studio

I have a relative layout in my XML file and it contains a button. Now I want that when I press this button, it creates 2 TextViews. Any help please because I am new to Android Studio? I have tried creating the onClickListener for the button but I am having problems in order to get an object of the current relative layout which I have in the XML.
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_brush_your_teeth);
Intent i = getIntent();
final Button addAlertButton = (Button)findViewById(R.id.AddAlert);
addAlertButton.setOnClickListener(new Button.OnClickListener(){
public void onClick(View v){
}
});
}
The following is the XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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.example.user.dentalapp.BrushYourTeeth"
tools:showIn="#layout/activity_main">
<!--ALERT 1-->
<TextView
android:id="#+id/Alert1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Alert 1"
android:textSize="25dp"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_marginTop="50dp"
android:layout_marginLeft="50dp"/>
<TextView
android:id="#+id/Time1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="08:00"
android:textSize="25dp"
android:onClick="showTimePickerDialog"
android:layout_above="#+id/Alert2"
android:layout_alignParentRight="true"
android:layout_marginRight="50dp"/>
<!--ALERT 2-->
<TextView
android:id="#+id/Alert2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Alert 2"
android:textSize="25dp"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_below="#id/Alert1"
android:layout_marginTop="30dp"
android:layout_marginLeft="50dp"/>
<TextView
android:id="#+id/Time2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="21:00"
android:textSize="25dp"
android:layout_below="#id/Alert1"
android:layout_marginTop="30dp"
android:layout_alignParentRight="true"
android:layout_marginRight="50dp"/>
<!--ADD ALERT BUTTON-->
<Button
android:id="#+id/AddAlert"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Add Alert"
android:textAllCaps="false"
android:textSize="25dp"
android:padding="15dp"
android:layout_below="#id/Alert2"
android:layout_centerHorizontal="true"
android:layout_marginTop="200dp"/>
</RelativeLayout>
Thanks!!
This link may be useful for you:
displaying a string on the textview when clicking a button in android
It is for one string, you may add your second text view into method below:
private void printmyname(){
System.out.println("coming");
}
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_brush_your_teeth);
final Button addAlertButton = (Button) findViewById(R.id.AddAlert);
addAlertButton.setOnClickListener(new Button.OnClickListener() {
public void onClick(View v) {
RelativeLayout layout = (RelativeLayout) findViewById(R.id.layout);
int prevTextViewId = 0;
final TextView textView1 = new TextView(this);
final TextView textView2 = new TextView(this);
textView1.setText("Text 1");
textView2.setText("Text 2");
int curTextViewId = v.getId();
textView1.setId(curTextViewId+1);
textView2.setId(curTextViewId+2);
final RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
params.addRule(RelativeLayout.BELOW, v.getId()+1);
textView1.setLayoutParams(params);
params.addRule(RelativeLayout.BELOW, v.getId()+2);
textView2.setLayoutParams(params);
layout.addView(textView1, params);
layout.addView(textView2, params);
}
});
}
Not sure but something like this helps you

enable edit box only after selecting the radio button

I have two radio buttons i.e., call and email. When call is selected then the edit box should get enabled and then user may enter the mobile number.
I've checked these links:
Enable a text box only when 1 of the radio button is clicked
Enable text box based on radio button selected
Making Text box not editable
but am not able to achieve this task.
Here is my code:
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp" >
<RadioGroup
android:id="#+id/radioGroup1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="2"
android:orientation="horizontal">
<RadioButton
android:id="#+id/radio0"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/call"/>
<RadioButton
android:id="#+id/radio1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="#string/email"
android:layout_weight="1" />
</RadioGroup>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:weightSum="1">
<TextView
android:id="#+id/textView21"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="#string/mobile"
android:textColor="#000000"
android:textSize="15sp"
android:layout_weight="0.3" />
<EditText
android:id="#+id/editText1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="numberDecimal"
android:maxLength="10"
android:layout_weight="0.7"
android:inputType="none" />
</LinearLayout>
.java
public class MainActivity extends Activity {
String mobile;
RadioGroup rg1 = (RadioGroup) findViewById(R.id.radioGroup1);
EditText edit = (EditText) findViewById(R.id.editText1);
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
edit.setEnabled(false);
edit.setInputType(InputType.TYPE_NULL);
edit.setFocusable(false);
rg1.setOnCheckedChangeListener(new OnCheckedChangeListener() {
#Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
switch (checkedId) {
case R.id.radio0:
op1="call";
actv();
break;
case R.id.radio1:
op1="email";
break;
}
}
});
public void actv() {
edit.setEnabled(true);
edit.setInputType(InputType.TYPE_CLASS_TEXT);
edit.setFocusable(true);
}
Besides correcting your member initialization (as suggested in each of the previous answers), you need to fix your layout (it is closed too early, resulting in an invalid xml).
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<RadioGroup
android:id="#+id/radioGroup1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:orientation="horizontal"
android:weightSum="2" >
<RadioButton
android:id="#+id/radio0"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/call" />
<RadioButton
android:id="#+id/radio1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:checked="true"
android:text="#string/email" />
</RadioGroup>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:weightSum="1" >
<TextView
android:id="#+id/textView21"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.3"
android:text="#string/mobile"
android:textColor="#000000"
android:textSize="15sp" />
<EditText
android:id="#+id/editText1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.7"
android:ems="10"
android:maxLength="10" />
</LinearLayout>
</LinearLayout>
Also decide which way you'd like to prevent the user from typing into the edittext (disable / hide / input type tweaks).
And last but not least, put all of these together in a clean manner:
public class MainActivity extends Activity implements OnCheckedChangeListener
{
private String op1;
private RadioGroup rg1;
private EditText edit;
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
rg1 = (RadioGroup) findViewById(R.id.radioGroup1);
rg1.setOnCheckedChangeListener(this);
edit = (EditText) findViewById(R.id.editText1);
actv(false);
}
#Override
public void onCheckedChanged(RadioGroup group, int checkedId)
{
switch (checkedId)
{
case R.id.radio0:
op1 = "call";
actv(true);
break;
case R.id.radio1:
op1 = "email";
actv(false);
break;
}
}
private void actv(final boolean active)
{
edit.setEnabled(active);
if (active)
{
edit.requestFocus();
}
}
}
#Zoya RadioGroup rg1 = (RadioGroup) findViewById(R.id.radioGroup1);
included this before onCreate method # MagicalPhoenixĻ” Not working
means the screen is not displayed..this is my 1st screen so as soon as
i start the app it says "the application has stopped
unexpectedly..please try again.."
It's giving crash.
REASON:
RadioGroup rg1 = (RadioGroup) findViewById(R.id.radioGroup1);
EditText edit = (EditText) findViewById(R.id.editText1);
You have included these before onCreate method.
This won't work, obviously.
Add that after your setContentView call inside onCreate method.
Hope it helps.
This is What you need to do
Change this
RadioGroup rg1 = (RadioGroup) findViewById(R.id.radioGroup1);
EditText edit = (EditText) findViewById(R.id.editText1);
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
to this
RadioGroup rg1 = null;
EditText edit = null;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
rg1 = (RadioGroup) findViewById(R.id.radioGroup1);
edit = (EditText) findViewById(R.id.editText1);
}
Thanks :)
add:
rg1 = (RadioGroup) findViewById(R.id.radioGroup1);
edit = (EditText) findViewById(R.id.editText1);
after:
setContentView(R.layout.activity_main);
in your onCreate();
Also make sure to set edit.setEditable(false) when radio1 is checked.
Complete Code:
public class MainActivity extends Activity {
String mobile;
RadioGroup rg1 = null;
EditText edit = null;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
rg1 = (RadioGroup) findViewById(R.id.radioGroup1);
edit = (EditText) findViewById(R.id.editText1);
edit.setEnabled(false);
edit.setInputType(InputType.TYPE_NULL);
edit.setFocusable(false);
rg1.setOnCheckedChangeListener(new OnCheckedChangeListener() {
#Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
switch (checkedId) {
case R.id.radio0:
op1="call";
enableEdit(true);
break;
case R.id.radio1:
op1="email";
enableEdit(false);
break;
}
}
});
}
public void enableEdit(boolean state) {
edit.setEnabled(state);
edit.setFocusable(state);
if(state){ edit.setInputType(InputType.TYPE_CLASS_TEXT); }
else { edit.setInputType(InputType.TYPE_NULL); }
}
}

how to add a button value to edittext

l have 3 buttons and 1 edittext
<Button
android:id="#+id/button1" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="1" />
<Button
android:id="#+id/button2" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="2" />
<Button
android:id="#+id/button3" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="3" />
<EditText
android:id="#+id/display" android:layout_width="match_parent"
android:layout_height="wrap_content" android:text="#string/result" />
when i click on android emulator button 1 the text value of 1 should display in edittext how can do this
you have a method button.getText() from which you can get the text of button 1 and then can update the edittext using edittext.setText() method
Just take the reference of that button from the xml layout file in your java file,the setOnClickListener() on it and override the method onClick() of the onClickListener().In that onClick method just set The text of the edittext to the one you wish to add into it.See this Android: How to set the contents of a Edit text from a Button click?
final Button b1 = (Button) findViewById(R.id.button1);
final EditText e1 = (EditText) findViewById(R.id.display);
b1.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
e1.setText(b1.getText().toString());
}
});
just copy paste this code it will surely work for you
Its working.
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
editText = (EditText) findViewById(R.id.edittext1);
button1 = (Button) findViewById(R.id.button1);
button2 = (Button) findViewById(R.id.button2);
button3 = (Button) findViewById(R.id.button3);
button1.setOnClickListener(this);
button2.setOnClickListener(this);
button3.setOnClickListener(this);
}
#Override
public void onClick(View v) {
Button button = (Button)v;
editText.setText(button.getText().toString());
}

Categories

Resources