Java 尝试使用底部工作表中的弹出窗口(Android)
我正试图在我的应用程序中从底部工作表打开一个弹出窗口,我希望它在底部工作表上方打开 这是我的密码Java 尝试使用底部工作表中的弹出窗口(Android),java,android,android-studio,Java,Android,Android Studio,我正试图在我的应用程序中从底部工作表打开一个弹出窗口,我希望它在底部工作表上方打开 这是我的密码 private void setUpPriorityPopUpWindow() { LayoutInflater inflater = (LayoutInflater) requireContext().getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); @SuppressLint(&q
private void setUpPriorityPopUpWindow()
{
LayoutInflater inflater = (LayoutInflater) requireContext().getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
@SuppressLint("InflateParams") View v = inflater.inflate(R.layout.tasks_priority_popup_window,null);
tasksPriorityPopUp = new PopupWindow(v, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT,true);
}
在我的BottomSheetFragment的OnCreateView中:
ImageButton priority = v.findViewById(R.id.priority);
setUpPriorityPopUpWindow();
priority.setOnClickListener(new View.OnClickListener() {
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
@Override
public void onClick(View v) {
tasksPriorityPopUp.showAsDropDown(v);
}
});
任何形式的帮助都将不胜感激
编辑:它当前在底页后面打开您应该使用
对话框
或对话框片段
,而不是膨胀视图
new AlertDialog.Builder(context)
.setTitle("Delete entry")
.setMessage("Are you sure you want to delete this entry?")
// Specifying a listener allows you to take an action before dismissing the dialog.
// The dialog is automatically dismissed when a dialog button is clicked.
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// Continue with delete operation
}
})
// A null listener allows the button to dismiss the dialog and take no further action.
.setNegativeButton(android.R.string.no, null)
.setIcon(android.R.drawable.ic_dialog_alert)
.show();
class PurchaseConfirmationDialogFragment : DialogFragment() {
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog =
AlertDialog.Builder(requireContext())
.setMessage(getString(R.string.order_confirmation))
.setPositiveButton(getString(R.string.ok)) { _,_ -> }
.create()
companion object {
const val TAG = "PurchaseConfirmationDialog"
}
}