Sorry if you seen this question asked severally but I seem to be stuck on something very basic with regards to the action bar.
Essentially I would like to place text on the far right/end of the action bar based on the engaged fragment. I'm aware of how menu buttons are placed there.
Having read up further on the action bar I'm aware of how menu options can be placed on the far right of the action bar but I can't seem to grasp how to place text on the far right/end of the action bar based on the engaged fragment.
At the moment below is how I've gone about customizing my action bar:
In my MainActivtiy.java I've got a custom layout that contains a textview which I set by calling a method contained in my MainActivtiy.java from the currently engaged fragment:
LayoutInflater inflator = (LayoutInflater) this
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View mCustomActionView = inflator.inflate(R.layout.actionbar, null);
tvActionBarTitle = (TextView) mCustomActionView.findViewById(R.id.title);
tvActionBarTitle.setTypeface(officialBoldFont);
tvActionBarTitle.setTextColor(Color.BLACK);
getActionBar().setCustomView(mCustomActionView);
getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_HOME);
getActionBar().setBackgroundDrawable(new ColorDrawable(0xffFFCC00));
getActionBar().setDisplayHomeAsUpEnabled(true);
getActionBar().setHomeButtonEnabled(false);
Below is the above mentioned method in my MainActivtiy.java which I call from the currently engaged fragment:
//
public void setActionBarTitle(String title) {
tvActionBarTitle.setText(title);
}
Below is how I call the above method from the currently engaged fragment:
//
((MainActivityNormal800by480) getActivity()).setActionBarTitle("LOG IN");
Below is the actionbar layout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent" >
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:textSize="25dp"
android:maxLines="1"
android:ellipsize="end"/>
</RelativeLayout>
Below is a screenshot and I have circled where I desire to place text using the oval shape:
Any ideas how I could place text on the far right/end of the action bar based on the engaged fragment.