This is very similar to many question already posted on stackoverflow, but I still haven't found the right solution. The problem I'm facing is how to implement a custom actionbar.xml file and add a navigation drawer function to the top left icon.
I'm trying to create an action bar that looks like this with two ImageButtons on side and an ImageView as a logo in the center. When user presses on the left ImageButton from actionbar.xml, I would like navigation drawer coming from the left, like in this tutorial . The last thing that troubles me, is how to put a title of pressed fragment in the center of the action bar instead of a logo.
I've already written all xml and java files, but I just can't put the pieces together. Please help.
I believe you have solution to create navigation drawer.
Now for your question HOW TO CREATE A CUSTOM ACTION BAR
Try like this ..
actionBar = getSupportActionBar(); // Get Action Bar reference.
actionBar.setCustomView(R.layout.action_bar_confirm_cabs); Set your action bar view like this
fare_ll = (TextView) actionBar.getCustomView().findViewById(R.id.fare_ll); Get id of your custom view like this ...
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); // Set property for Custom view like this.
fare_ll.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
}
});
That's it.... You are good to go.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.