need help to create custom keypad INSIDE a dialogFragment. do not want system keyboard to pop out

163 views Asked by At

i have created an XML and dialog fragment consist of Edittext and numeric buttons (keypad). i had searched alot but only found creating custom softkey solutions. my objective is very simple. i already had all the buttons created in XML. what should i add to so that when "1" is pressed, edittext will display "1", "2" is pressed display "12", 3 will display "123"... etc. some source code for me would be useful, I know how to display "1" in edit text when i pressed "1", which method to use to display 2 next to 1 when i press 2

enter image description here

1

There are 1 answers

1
c0m3tx On BEST ANSWER

In XML insert onClick commands for each button. In your activity, create a method for each onClick defined, this way:

In XML:

<Button ...
    android:onClick="one" />

In the activity you should have a method like this one:

public void one(View v) {
    yourEditText.setText(yourEditText.getText().toString() + "1");
}

It should work. You can always use getText() to get the content and setText(newText) to set the content. Please note that if you click on the EditText this way you will still get the system keyboard pop up, if you want to only show the value use a TextView instead.

Hope it helps.