Android getActionBar (). SetTitle not working

ActionBar - setTitle does not seem to be called. Everything I do with an ActionBar (like HomeIsUp, etc.) goes well, but setTitle is not.

Here is a simple activity code:

public class GuidelineDetails extends Activity implements OnClickListener {

    String guideline_name;
    String guideline_attachment;

    public static TextView tv_title;
    public static TextView tv_intro;
    public static TextView tv_test;
    public static WebView webview;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.guideline_detail);
        getActionBar().setTitle("Privet");
        getActionBar().setHomeButtonEnabled(true);
        getActionBar().setDisplayHomeAsUpEnabled(true);
        getActionBar().setDisplayShowTitleEnabled(false);
        getActionBar().setIcon(R.drawable.listbullet);

///// some code
}
}

Why doesn't he set the title?

in manifest:

<activity
            android:name=".GuidelineDetails"
            android:configChanges="orientation"
            android:label="Guideline"
            android:screenOrientation="portrait"
            android:theme="@android:style/Theme.Holo.Light" >
        </activity>

in layout:

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <TableLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content" >

            <TableRow
                android:id="@+id/tableRow1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" >

                <TextView
                    android:id="@+id/guideline_title"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:paddingBottom="1dp"
                    android:paddingLeft="10dp"
                    android:paddingRight="1dp"
                    android:paddingTop="35dp"
                    android:textSize="18dp"
                    android:textStyle="bold" />
            </TableRow>

        </TableLayout>
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="0.16"
        android:orientation="vertical" >     

         <TableRow
                android:id="@+id/tableRow4"
                android:layout_width="match_parent"
                android:layout_height="match_parent" >

          <WebView
    android:id="@+id/webviewD"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
/>

        </TableRow>



    </LinearLayout>

</LinearLayout>
+4
source share
5 answers

due to

getActionBar().setDisplayShowTitleEnabled(false);

change it to

getActionBar().setDisplayShowTitleEnabled(true);
+20
source

Have you tried installing subTitle? Because in some cases, if the device screen is small in the ActionBar, you can only see the ActionBar icon. Try this.getActionBar (). SetTitle ("Privet"); Hope this helps you!

0
source

I think this is because the manifest file is above its rules. I had the same problem with my icon, so I just had to change it in the manifest file ( android:label="Guideline") or not try to set the label in the manifest if you need to set it grammatically.

0
source

Try expanding ActionBarActivity instead of Activity

0
source

Although this has been resolved, I am adding this answer for everyone who also has this problem. Make sure your minimum API is 11.

 {Rich}
0
source

All Articles