2013-09-04 4 views
0

경고 대화 상자를 표시하는 데 'DialogFragment'를 사용하고 있습니다. 내 요구 사항은 2.3에서 시작하는 안드로이드의 서로 다른 버전에 걸쳐 응용 프로그램의 모든 대화 상자 조각에 대한 동일한 테마를 가지고 있습니다. 하지만 테마를 적용 할 수 없습니다. 내 코드DialogFragment가있는 AlertDialog에 스타일이 적용되지 않습니다.

<style name="Dialog" parent="@android:style/Theme.Dialog"> 
    <item name="android:windowTitleStyle">@style/MyOwnDialogTitle</item> 
</style> 

<style name="MyOwnDialogTitle" parent="android:Widget.TextView"> 
    <item name="android:background">@android:color/darker_gray</item> 
    <item name="android:drawableRight">@android:drawable/ic_menu_add</item> 
</style> 
입니다

public class MyDialogFragment extends DialogFragment{ 

     @Override 
     public Dialog onCreateDialog(Bundle savedInstanceState) { 
      Context context = new ContextThemeWrapper(getActivity(), R.style.Dialog); 
      AlertDialog.Builder builder = new AlertDialog.Builder(context); 
      builder.setTitle("Title"); 
      builder.setMessage("Message"); 
      builder.setPositiveButton("Ok", null); 
      return builder.create(); 
     } 
} 

나를 제발 도와주세요

enter image description here

같은 2.3 에뮬레이터 내 출력입니다.

감사합니다.
샤.

답변

0

교체 <style name="MyOwnDialogTitle" parent="android:Widget.TextView">

<style name="MyOwnDialogTitle" parent="@android:style/Widget.TextView"> 
관련 문제