我想基於這個代碼DialogFragment實現AlertDialog:如何使用AlertDialog從DialogFragment中刪除奇怪的邊框?
public class AlertDialogFragment extends DialogFragment {
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
return new AlertDialog.Builder(getActivity())
.setTitle("title")
.setMessage("message")
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
})
.setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
})
.create();
}
}
它運作良好,但我避開AlertDialog一個奇怪的白色邊框:
如何刪除此邊界(最好以編程方式)?
UPDATE:我styles.xml包含此代碼:
<style name="AppBaseTheme" parent="@android:style/Theme.Holo.Light">
<item name="android:alertDialogTheme">@style/MyDialogTheme</item>
</style>
<style name="MyDialogTheme" parent="@android:style/Theme.Holo.Light.Dialog"></style>
當我刪除<item name="android:alertDialogTheme">@style/MyDialogTheme</item>
行,這個問題消失。但我需要這一行,因爲我想自定義AlertDialog。如何解決這種風格?
能否請您發佈您的代碼,你正在使用這個'對話框Fragment'? @PartWell – Pooja
@Pooja,我用代碼'new AlertDialogFragment()。show(getFragmentManager(),「TAG_HERE」);'調用它。 – BArtWell
已經回答 http://stackoverflow.com/questions/2644134/android-how-to-create-a-dialog-without-a-title – Don