Niko Gamulin
Niko Gamulin

Reputation: 66565

setting the key listener to a custom View

I created a custom View Round button which consists of an image and some text. I tried to bind a method to it but it doesn't work and don't know what could be the reason.

In the main.xml (layout file) i set the parameter clickable to true and in the onCreate method in the main activity i added the following lines:

rbActionButton = (RoundButton)findViewById(R.id.actionButton);

    rbActionButton.setOnClickListener(new OnClickListener(){
        public void onClick(View view){
            onActionButton();
        }
    });

Does anyone know whether there's anything missing or the reason it doesn't work?

Thanks!

Upvotes: 0

Views: 2824

Answers (1)

Sudhakar Chavali
Sudhakar Chavali

Reputation: 829

Yes this doesnot work because you need key listener but you are trying with ClickListener.

http://developer.android.com/reference/android/text/method/KeyListener.html

Upvotes: 1

Related Questions