Reputation: 111
Bellow mentioned is the code where i am registering framelayout for long click listener event.
private void createActivityLayout(Fragment fragment)
{
FrameLayout frameLayout = (FrameLayout)getLayoutInflater().inflate(R.layout.professional_pa_frame_layout, null, false);
frameLayout.setClickable(true);
frameLayout.setOnLongClickListener(new View.OnLongClickListener()
{
public boolean onLongClick(View view)
{
if (actionMode == null)
{
return false;
}
actionMode = view.startActionMode(actionModelCallback);
view.setSelected(true);
return false;
}
});
getFragmentManager().beginTransaction().add(id, fragment, tag).commit();
}
The fragment internally contains a series of edittext instances or a single imageview instances.
Whenever a long click is performed on framelayout, i guess the contextual action bar for edittext is displayed. I think the event is captured by editext and different contextual action bar is displayed. PFA image of the contextual action bar displayed whenever i get a long click event inside framelayout.
How can i capture long click event on my framelayout as a whole without displaying contextual action bar for its internal views. xml code written below is of the contextual action bar that i want to be displayed for my framelayout.
<item android:id="@+id/action_discard_notes"
android:icon="@drawable/discard_note"
android:title="@string/action_discard_notes"
android:showAsAction="always"
android:orderInCategory="1"/>
Upvotes: 0
Views: 561
Reputation: 245
You need to set ActionModeCallback of Edittext so CAB aborted and call Framelayout long click like below code...
m_editText.setCustomSelectionActionModeCallback(new Callback()
{
@Override
public boolean onCreateActionMode(android.view.ActionMode p_mode, Menu p_menu)
{
return false;
}
@Override
public boolean onPrepareActionMode(android.view.ActionMode p_mode, Menu p_menu)
{
return false;
}
@Override
public void onDestroyActionMode(android.view.ActionMode p_mode)
{
}
@Override
public boolean onActionItemClicked(android.view.ActionMode p_mode, MenuItem p_item)
{
return false;
}
});
You need to return false in onCreateActionMode for abort CAB(contextual action bar).
Upvotes: 1