I am wondering how to animate going into and out of the contextual action mode. I am looking for an animation like in the app AwSms when you long press on a conversation (image provided, sorry for no video) The animation is essentially a ripple that comes from the middle and expands outwards on the Action Bar. I have searched long and far with no foreseeable way to animate the contextual action mode. It was definitely done here but I am not sure how. Thank you very much in advance!
Things I have tried:
public ActionMode.Callback iconEditCallback = new ActionMode.Callback() {
#Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
MenuInflater inflater = mode.getMenuInflater();
inflater.inflate(R.menu.menu_iconmanager_edit, menu);
mode.getCustomView().startAnimation(ripple);
return true;
}
I also tried:
getSupportActionBar.setShowHideAnimationEnabled(true);
Related
i need Help, i'm working on a Simple Text Editor and i want to implement a custom Menu Copy Past Cut .. and more, but to do that i need to Hide the Original Menu, My problem is just in this Step of Hiding the original Menu (Copy.. Past..) it Kepp showing while using the common ways, such as the first bellow Code.
this way not working at all.
and also the way of disabling the long click (if disabling the Long click we can't select the Text) and if text not selected can't use my custom menu.
in some Application such as Code Editor, have this function :
so, which way i follow to implement this ? can you guide/help me plz ! bcz now all steps is ok for me (when selecting text my menu appear) But also the original Menu (copy past cut) appear and i want to disable it...
the Code Bellow not working and the screen shot show that
edittext.setCustomSelectionActionModeCallback(new ActionMode.Callback() {
public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
return false;
}
public void onDestroyActionMode(ActionMode mode) {
}
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
return false;
}
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
return false;
}
});
finally i got the solution with help of guide in web, and with my own search, no body wanted to share the solution with me.
after i got it, i want to share with you. maybe it helps someone.
the suggestions shared all not working, some will disable selecting texts and others also do this + not working on all api..
in my case the editText id is edittext1.
in your activity past the bellow code :
private class MyActionModeCallback implements ActionMode.Callback {
private Menu mMenu;
#Override
public boolean onCreateActionMode(ActionMode actionMode, Menu menu) {
return true;
}
#Override
public boolean onPrepareActionMode(ActionMode actionMode, Menu menu) {
//After the menu is created, the object is obtained for subsequent operations
this.mMenu=menu;
mMenu.clear();
return true;
}
#Override
public boolean onActionItemClicked(ActionMode actionMode, MenuItem menuItem) {
switch (menuItem.getItemId()){
}
return true;
}
#Override
public void onDestroyActionMode(ActionMode actionMode) {
}
}
and how to use it :
edittext1.setCustomSelectionActionModeCallback(new MyActionModeCallback());
I wanted to hide Contextual action bar in webview long press click. Is there any way to hide or disable it. I tried with below code:
webView.setOnLongClickListener(new View.OnLongClickListener() {
#Override
public boolean onLongClick(View v) {
return true;
}
});
But I don't want to disable long press click. In short I want both long press to be working and CAB to be hide or disable in webview. Is it possible ? any solution welcome. Thanks
Want to hide or disable Contextual Action Bar looks like:
I am using Google My Tracks code from here in my app.
Although in the app itselfthe menu bar is visible. when I integrate it in my app I cannot see the menu bar.
The code is exactly the same.
In the following code I cannot see the system.out.println message.
#Override
public boolean onCreateOptionsMenu(Menu menu) {
System.out.println("Menu created");
getMenuInflater().inflate(R.menu.track_list, menu);
menu.findItem(R.id.track_list_feedback)
.setVisible(ApiAdapterFactory.getApiAdapter().isGoogleFeedbackAvailable());
searchMenuItem = menu.findItem(R.id.track_list_search);
ApiAdapterFactory.getApiAdapter().configureSearchWidget(this, searchMenuItem, trackController);
startGpsMenuItem = menu.findItem(R.id.track_list_start_gps);
refreshMenuItem = menu.findItem(R.id.track_list_refresh);
exportAllMenuItem = menu.findItem(R.id.track_list_export_all);
importAllMenuItem = menu.findItem(R.id.track_list_import_all);
deleteAllMenuItem = menu.findItem(R.id.track_list_delete_all);
return true;
}
If it makes any difference, in all my other activities except the ones imported from this project, I do not use the menu bar.
If this code resides inside a Fragment, make sure you call setHasOptionsMenu(true) in onCreate() method of this Fragment.
When I touch this "Edit" button I want it to change to "Done". Is there a way to do this?
I tried this but it only works when opening the menu on the right side:
#Override
public boolean onPrepareOptionsMenu(Menu menu) {
// change the text here.
return super.onPrepareOptionsMenu(menu);
}
I assume that, at some point, you inflate the menu, yes?
#Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.some_menu_layout, menu);
return true;
}
So you can go into your menu (in this case, res/menu/some_menu_layout.xml), and find the android:id of the menu item you want to find. You should then be able to use menu.findItem(theId).setTitle("Done");. (You may have to save your Menu variable as a local member to do this.)
I'm trying to get my options menu to show up in the new Android 3.0 system bar. I can get this behavior to work with the Notepadv3 tutorial. However, when implementing nearly the identical functions, the menu shows in the above action bar, but not the system bar. Any ideas?
Attached is the appropriate code for my application:
public class AACUser extends Activity {
private static final int ADMIN_ID = Menu.FIRST;
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
menu.add(0, ADMIN_ID, 0, R.string.menu_admin);
return true;
}
#Override
public boolean onMenuItemSelected(int featureId, MenuItem item) {
switch(item.getItemId()) {
case ADMIN_ID:
enterAdminMode();
return true;
default:
return super.onMenuItemSelected(featureId, item);
}
}
}
I've also tried implementing these menu functions as recomended by the creating menu documentation:
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.user_menu, menu);
return true;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle item selection
switch (item.getItemId()) {
case R.id.menu_adminMode:
enterAdminMode();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
but no difference: it still displays the option in the overflow of the action bar, but not the system bar.
As of Android 3.0, the options menu is not required (if not deprecated). If you target API 11 (Android 3.0) or later, it is assumed that your app will work without an options menu, so the system bar will not display one. The options menu in the system bar is only there for backwards compatibility with old applications. New applications should have another affordance for accessing options, such as that provided by the action bar.
I think that the menu button in the system bar is for backward compatibility purposes only. So if you want to design your app for Honeycomb then the menu should be and will be in the action bar.