1

I want to achieve 1 of these options for my EditText :

  • Replace the actionbar that appear on the top by a popup menu instead. Something like this for exemple:

enter image description here

  • Or make the actionbar floating and child of my current view (in some way same a first option)

i need this because i add my view via windowManager.addView(view, Layout_Params); and in this way i have some trouble with the actionbar on the top (it is displayed blank)

actually i do this to show the actionbar :

@Override
public ActionMode startActionMode(ActionMode.Callback callback) {
    Activity host = (Activity) this.getContext();    
    return host.getWindow().getDecorView().startActionMode(callback); 
}

but it's don't work, it's show me an empty white actionbar on the stop instead :( i think i need to create myself the ActionMode but i don't know how to do it.

zeus
  • 12,173
  • 9
  • 63
  • 184

1 Answers1

0

Ok. You can hide the actionbar when your edittext is gained focus. Then you need to show the popup menu where ever you want.

EditText t = new EditText(this);
    t.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View view, boolean b) {
            if(b){
                getSupportActionBar().hide();
                //now show your popup menu at the top position
            }else{
                getSupportActionBar().show();
                //here you dismiss the menu.
            }

        }
    });
Tushar Monirul
  • 4,944
  • 9
  • 39
  • 49