2012-03-15 11 views
5

アンドロイドアプリでダイアログのカスタムテーマを作成しました。ダイアログタイトルに使用するレイアウトを上書きする予定でした。私は標準のアンドロイドでそれを見たThemeは、変更するように見えるこの属性があります。Androidのダイアログタイトルオーバーライドを無効にする

<item name="dialogTitleDecorLayout">@layout/dialog_title</item> 

しかし、私は次のエラーを参照してください私のTheme

<style name="Theme.Dialog.MyDialog" parent="android:Theme.Dialog"> 
    <item name="android:windowBackground">@android:color/black</item> 
    <item name="android:dialogTitleDecorLayout">@layout/my_dialog_title</item> 
</style> 

でそれを上書きしようとすると:

No resource found that matches the given name: attr 'android:dialogTitleDecorLayout'

なぜそれを変更することが、私はどのように知ることができ、私ができませんでした属性を変更することはできますか?

+0

は、あなたのスタイルのための完全なXMLファイルを表示することができonclickのボタンイベントに表示される方法とは?それはあなたがそこにアンドロイドのためのXMLスキーマが不足している可能性がありますか? – Genry

答えて

1

このような項目を上書きすることはできません。あなたは必要なレイアウトでダイアログをカスタマイズしなければなりません。レイアウトでは、ここであなたの必要条件にテーマを適用する必要があります。

dialog_title.xml 

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

<TextView 
    android:id="@+id/text" 
    android:text="@string/tell_a_friend" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:paddingLeft="8dip" 
    android:paddingTop="12dip" 
    android:paddingBottom="12dip" 
    style="@style/bigTextWhite" /> 

</LinearLayout> 

//これはあなたのダイアログが

public void onClickHelp(View v) { 
    final Dialog duDialog = new Dialog(this); 
    duDialog.setContentView(R.layout.data_usage); 
    duDialog.getWindow().setBackgroundDrawableResource(R.color.title_text); 

    duDialog.setTitle("Data Usage"); // I would like to set the color and add button here 
    ListView data = (ListView) duDialog.findViewById(R.id.DataUsage); 
    duCursor = Data.getAll(db); 
    startManagingCursor(duCursor); 
    duAdapter = new DataAdapter(duCursor); 
    data.setAdapter(duAdapter); 
    duDialog.show(); 

} 
関連する問題