检测操作栏中的图标长preSS栏中、图标、操作、preSS

2023-09-12 02:56:28 作者:何必挽离人

我要检测在Android应用程序中的动作条应用程序的图标长preSS。这可能吗?

I want to detect long press on application's icon in the ActionBar in Android application. Is it possible?

推荐答案

添加自定义视图操作栏

    View view     = getLayoutInflater().inflate(R.layout.actionbar,null);
    btnClose    = (ImageView) view.findViewById(R.id.btnClose);
    btnClose.setOnLongClickListener(new OnLongClickListener()
    {

        @Override
        public boolean onLongClick(View v) {
            Log.d("rvg", "Long click:");
            return false;
        }
    });



  getSupportActionBar() . setCustomView(view);