Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android ActionBar options long click event

Android Can anyone know about Actionbar item options long click , I want to show text on LongClick on actionbar menu option like a hint on long press of actionBar long press

like image 353
user1206890 Avatar asked Nov 27 '22 18:11

user1206890


1 Answers

Do you want to capture long press on menu item on action bar? As for me, after finding 2,3 hour, I found this solution. This is perfectly work for me.

      @Override
     public boolean onCreateOptionsMenu(final Menu menu) {



    getMenuInflater().inflate(R.menu.menu, menu);

    new Handler().post(new Runnable() {
        @Override
        public void run() {
            final View v = findViewById(R.id.action_settings);

            if (v != null) {
                v.setOnLongClickListener(new CustomLongOnClickListener());
            }
        }
    });

    return true;
}
like image 132
YeeKhin Avatar answered Dec 05 '22 17:12

YeeKhin