Context menu for a button using android?

627 views Asked by At

I have a button that when pressed, will call the company. Now, I was doing some research and found that there is a way to include a context menu. I really like the context menu because it gives you so many options.

Do you think it would be a waste of code to set a context menu for a click of the button that when pressed will open up the options to add contact, call contact, sms contact, etc.? Is it necessary?

I did come across these: Android opening context menu after button click http://developer.android.com/guide/practices/ui_guidelines/menu_design.html#tour_of_the_menus

2

There are 2 answers

5
coder_For_Life22 On BEST ANSWER

I think it would be a good feature to include. Thats what context menu is there for, to give more options. I think it would be good to give the user more options when the button is clicked. Well it makes more since anyway.

Heres how you would get the long click

Button downSelected = (Button) findViewById(R.id.downSelected);
    downSelected.setOnLongClickListener(new OnLongClickListener() { 
    @Override
    public boolean onLongClick(View v) {
        // TODO Auto-generated method stub
        return true;
    }
});

EDIT:

If you just want one click on the button just register its click listener like this..

downSelected.setOnClickListener(new View.OnClickListener() {
         public void onClick(View v) {
             // Perform action on click
         }
     });
 }
2
Snicolas On

It would be nice to provide a big main button to call the number, and some additional mechanism, let's say a smaller + button to do more stuff with as you sugggested. Also a long click could be considered a right user interaction to provide with more features.

Just a user feeling...