Android ActionBar options long click event

前端 未结 6 1133
南方客
南方客 2020-12-18 08:53

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 pres

6条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-18 09:13

    I think "findViewById" is the easiest way to find.
    Just do

    View action_example = findViewById(R.id.action_example);
            if(action_example!=null)action_example.setOnLongClickListener(
                    new View.OnLongClickListener() {
                        @Override
                        public boolean onLongClick(View v) {
                            Toast.makeText(MainActivity.this, "action_example", Toast.LENGTH_SHORT).show();
                            return true;
                        }
                    }
            );
    

提交回复
热议问题