1

I wanted to develop an on screen keyboard similar to the square app (image below)enter image description here

I would appreciate it if anyone could give me tips on which classes to focus on/ override for this. In particular, how do I associate the button clicks to the number input in the EditText field?

bpn
  • 3,082
  • 2
  • 19
  • 22
  • http://stackoverflow.com/questions/3480715/how-to-develop-a-soft-keyboard-for-android – calsign Aug 28 '12 at 17:25
  • I think the approach would be different considering this is not a keyboard which pops up/out when you click on the edittext. The keyboard is pretty much a view and is present on the screen always. – bpn Aug 28 '12 at 17:30
  • 2
    `KeyboardView`: http://stackoverflow.com/a/11923742/503900 – bigstones Aug 28 '12 at 17:33

1 Answers1

4

Every Button gets a Tag with the associate value (for example 1). Then, you use the android:onClick-attribute to set all buttons to the same method (input() for example) in the activity.

This method will be called with the clicked view, which you can then use the getTag()-method on to get the corresponding value:

// Will be called for every Button that is clicked
public void input(View v){
  Log.v("APP", "Pressed: "+v.getTag());
}

Organize the Buttons in a GridLayout (GridView might also be possible).

Lukas Knuth
  • 25,449
  • 15
  • 83
  • 111