J'ai créé une barre de titre personnalisée avec les éléments suivants.Android: Titre non affiché dans la barre de titre personnalisée avec affichage ListAdapter personnalisé
myapptitle.xml
<?xml version="1.0" encoding="utf-8"?>
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/myTitle"
android:text="@string/app_name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="@color/titletextcolor"
android:textSize="14sp"
android:layout_gravity="top"
/>
themes.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="customTheme" parent="android:Theme">
<item name="android:windowTitleBackgroundStyle">@style/WindowTitleBackground</item>
<item name="android:windowTitleSize">40dip</item>
</style>
</resources>
manifext.xml
<application
android:label="@string/app_name"
android:theme="@style/customTheme" >
.....
J'ai créé un cu stomList adapter et une mise en page pour celle-là comme celle ci-dessous.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ImageView
android:id="@+id/icon"
android:layout_width="22dip"
android:layout_height="22dip"
android:layout_marginLeft="4dip"
android:layout_marginRight="10dip"
android:layout_marginTop="4dip"
android:contentDescription="@string/app_msg_title"
android:src="@drawable/logo_small" >
</ImageView>
<TextView
android:id="@+id/msgDate"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="14sp"
/>
<TextView
android:id="@+id/msgTitle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="14sp" />
<TextView
android:id="@+id/label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@+id/label"
android:textSize="12sp" >
</TextView>
</LinearLayout>
Dans mon activité de liste, j'ai donné le code ci-dessous à la méthode onCreate.
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,
R.layout.myapptitle);
Mais de toute façon, lors de l'exécution de l'application, je reçois la barre de titre sans aucun texte. Dans mon string.xml pour app_name j'ai Mes notifications comme texte.
Appréciez tout votre temps et aidez-nous.
Edité styles.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="WindowTitleBackground">
<item name="android:background">@color/titlebackgroundcolor</item>
</style>
</resources>
fournissent l'ensemble du fichier style.xml. – Riser
Salut Achille, nous y voilà. Xml version = "1.0" encoding = "utf-8"?> \t \t \t - @ couleur/titlebackgroundcolor
\t –
Jerokdeep
où allons-nous? .. – Riser