SORU
21 EKİM 2014, Salı


Android uygulaması Araç.setTitle yöntemi etkisi – uygulama adı, başlık olarak gösterilir vardır

Basit Uygulama android-support-v7:21 kütüphane oluşturmak için çalışıyorum.

Kod parçacıkları:
MainActivity.java

public class MainActivity extends ActionBarActivity {

    Toolbar mActionBarToolbar;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        mActionBarToolbar = (Toolbar) findViewById(R.id.toolbar_actionbar);            
        mActionBarToolbar.setTitle("My title");
        setSupportActionBar(mActionBarToolbar);
}

activity_main.xml

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    android:orientation="vertical">

    <android.support.v7.widget.Toolbar            
        android:id="@ id/toolbar_actionbar"
        android:background="@null"
        android:layout_width="match_parent"
        android:layout_height="?actionBarSize"
        android:fitsSystemWindows="true" />

</LinearLayout>

Ama "Benim başlık" Araç %uygulama adı% gösterilir. yerine
setTitle yöntemi gibi görünüyor hiçbir etkisi olmaz.
Göstermek istiyorum "Benim başlık".

UDP: , styles.xml önce:

<style name="AppTheme" parent="Theme.AppCompat">
    <item name="windowActionBar">false</item>
</style>

Yani, bu actionbar kullanılmaz sanıyordum. Stil üst NoActionBar ekleyin:

<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
    <item name="windowActionBar">false</item>
</style>

Ama sorun çözümlenemedi.

Herhangi bir yardım çok takdir edilir.

CEVAP
22 EKİM 2014, ÇARŞAMBA


Çözüm buldu
Yerine:

mActionBarToolbar = (Toolbar) findViewById(R.id.toolbar_actionbar);            
mActionBarToolbar.setTitle("My title");
setSupportActionBar(mActionBarToolbar);

Ben kullanın:

mActionBarToolbar = (Toolbar) findViewById(R.id.toolbar_actionbar);            
setSupportActionBar(mActionBarToolbar);
getSupportActionBar().setTitle("My title");

Ve işe yarıyor.

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • ☆ SUB4SUB CENTER! ☆ spam here

    ☆ SUB4SUB

    22 ŞUBAT 2010
  • Dylan Dubay

    Dylan Dubay

    10 Temmuz 2013
  • erikbjgn's channel

    erikbjgn's c

    12 Mayıs 2008