I'm trying to follow the answers of this question: Cancel Done buttons in Calendar App - Is it part of Action Bar? I want to do create that custom action bar
I'm noob on Android, so my questions are: I have to code a Fragment? How can I do this? I created a method to set the custom bar, I'm calling at onCreateView, it's not working...The action bar doesn't appears.
private void createCustomActionBar(){
inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View actionBarButtons = inflater.inflate(R.layout.custom_action_bar,
new LinearLayout(MyActivity.this), false);
View cancelActionView = actionBarButtons.findViewById(R.id.action_cancel);
cancelActionView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
try {
processForm();
} catch (Exception e) {
e.printStackTrace();
}
}
});
View doneActionView = actionBarButtons.findViewById(R.id.action_done);
// doneActionView.setOnClickListener();
this.getActionBar().setCustomView(actionBarButtons);
}
I already copied the xml's, color, drawables from the github's project.