【问题标题】:Detecting action bar icon long press检测操作栏图标长按
【发布时间】:2013-08-09 11:53:26
【问题描述】:

我想在 Android 应用程序的 ActionBar 中检测对应用程序图标的长按。有可能吗?

【问题讨论】:

    标签: android android-actionbar


    【解决方案1】:

    不幸的是,标准的 android 工具不提供这种可能性。

    唯一可行的方法是创建自己的actionLayout,见android:actionLayout

    我认为,这个问题与 Android ActionBar options long click event

    【讨论】:

      【解决方案2】:

      将自定义视图添加到操作栏

          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);
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多