Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7533465
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T05:44:00+00:00 2026-05-30T05:44:00+00:00

For starters, any help would be greatly appreciated! I have created a numerical keypad

  • 0

For starters, any help would be greatly appreciated! I have created a numerical keypad and I need to pass the numeric values to an EditText every time one of the buttons is selected. I’m running into a problem where the EditText is being overwritten by setText, every time a different button is pressed. I really need to concatenate each value, and I’m not quite sure how to do this. Any of the one to nine buttons could be pressed in any order.

Here is some of the code. I’m just trying to get these keys working first.

    View hash = findViewById(R.id.keypad_hash);
    hash.setOnClickListener(this);
    View key1 = findViewById(R.id.keypad_1);
    key1.setOnClickListener(this);
    View key2 = findViewById(R.id.keypad_2);
    key2.setOnClickListener(this);

}




@Override
public void onClick(View v){
switch(v.getId()){
case R.id.keypad_hash:
    questions();
    break;

case R.id.keypad_1:

    final EditText number_edit_text1 = (EditText) this.findViewById(R.id.Edit);
      number_edit_text1.setText(String.valueOf("1"));




      break;


case R.id.keypad_2:

    final EditText number_edit_text2 = (EditText) this.findViewById(R.id.Edit);
      number_edit_text2.setText(String.valueOf("2"));
    break;

}   
}

and then the edittext in the layout

<EditText  
android:id="@+id/Edit"  
android:layout_height="wrap_content"    
android:inputType="number"  
android:layout_width="fill_parent"
android:numeric="integer">  
</EditText> 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T05:44:02+00:00Added an answer on May 30, 2026 at 5:44 am

    Try:

    number_edit_text2.append(String.valueOf("2"));
    

    If that for some reason doesn’t work:

    number_edit_text2.setText(number_edit_text2.getText().toString()+String.valueOf("2"));
    

    Also, on a side note, you can make the process easier on yourself.

    In your xml, you should do:

    android:tag="0"
    

    and replace 0 with whatever number you want for each button.

    In your class body, you should declare EditText editText;, then in onCreate, you should do editText = (EditText)findViewById(R.id.Edit);

    Then in onClick, just do:

    editText.append(String.valueOf(v.getTag()));
    

    This should simplify your code, make it more manageable, and use ever so slightly fewer resources since you don’t have to repeatedly recreate the EditText.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ok, a few things I'm not quite sure about. For starters: I have a
Still an iphone dev starter but trying. I would like to have the user
I have a problem in silverlight which I need to convert this image(from database
I am developing a unit converter for my semester project. I need some help
I am relatively new to mod_rewrite, but have a site which I would like
I am fighting with CoreData again and i need your help :P I am
i have this JSON (at the link), and i need to remove some strings
So for starters lets say that I have a LinkedList<String> , I can easily
Are there any VS template/Starter Kit/Any example of an ASP.NET Web Application, which uses
Is there any essential difference between this code: ThreadStart starter = new ThreadStart(SomeMethod); starter.Invoke();

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.