简体   繁体   中英

How do i open an edit text popup on actionbar menu click

I am trying to display a popup edit text when "action_guess" is clicked. i am not sure on how to go about this. here is my code:

    public MyMenuItemClickListener() {
    }

    @Override
    public boolean onMenuItemClick(MenuItem menuItem) {
        switch (menuItem.getItemId()) {
            case R.id.action_guess:
                Toast.makeText(mContext, "guess code", Toast.LENGTH_SHORT).show();
                return true;
            default:
        }
        return false;
    }

If you want an EditText in a Dialog , you can follow this example. https://www.mkyong.com/android/android-prompt-user-input-dialog-example/

If you want it appear in the ActionBar , you can overlay the EditText inside the ActionBar layout and show/hide with setVisibility() .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM