我試圖使類似於此的對話框:用標題創建全屏對話框和取消/ OK按鈕
但無論是Android開發者指南,也沒有見到能解決我的問題問題:
標題不顯示,我只是得到我的服裝佈局。
我不知道如何在左邊放一個「x」,在右邊放一個保存圖標!它應該與WINDOW FEATURES一起使用嗎?
的dialogfragment代碼:
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
return inflater.inflate(R.layout.dialogfragment_statsentry, container, false);
}
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
Dialog mDialog = super.onCreateDialog(savedInstanceState);
mDialog.setTitle("hello");
return mDialog;
}
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
}
的dialogfragment XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:minWidth="600dp"
android:layout_height="match_parent"
android:minHeight="400dp"
android:orientation="vertical"
android:padding="10dp">
<TextView
android:id="@+id/dialog_statsentry_txvTime"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.TextInputEditText
android:id="@+id/dialog_statsentry_edtName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPersonName" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
我如何調用對話框:
StatsEntryFragmentDialog mFragment = new StatsEntryFragmentDialog();
FragmentManager mManager = getSupportFragmentManager();
if (Utils.isTablet(getApplicationContext())) {
mFragment.show(mManager, mFragment.TAG); // no fullscreen for bigger displays
}
else {
FragmentTransaction mTransaction = mManager.beginTransaction();
mTransaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
mTransaction.add(CONTENT_CONTAINER, mFragment).addToBackStack(mFragment.TAG).commit();
}
提前感謝!
它也更好窗口開始對話主題活動。 – Piyush
我不知道你的意思? –
請參閱此鏈接https://stackoverflow.com/questions/18315343/android-make-a-dialog-appear-in-fullscreen –