gpt4 book ai didi

android - DialogFragment 按钮推出屏幕 API 24 及更高版本

转载 作者:行者123 更新时间:2023-12-04 23:58:13 26 4
gpt4 key购买 nike

我正在制作一个显示可选数据列表的自定义 DialogFragment。列表太长,不滚动就无法显示在屏幕上。对于 API 23,一切似乎都运行良好,但当我在 API 24+ 上测试时,DialogFragment 的按钮不再可见。我看了Missing buttons on AlertDialog | Android 7.0 (Nexus 5x) ,但这似乎并不适用,因为当我减少列表中的内容量以使其全部适合屏幕时,我的按钮确实会出现。如何让我的按钮可见?

我的 onCreateDialog() 方法:

@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
final View dialogView = View.inflate(getContext(), android.R.layout.select_dialog_multichoice, null);

builder.setView(dialogView)
.setTitle(R.string.muscle_groups)
.setMultiChoiceItems(Exercise.MUSCLE_GROUPS, selectionTrackingArray, new DialogInterface.OnMultiChoiceClickListener() {
@Override
public void onClick(DialogInterface dialog, int which, boolean isChecked) {
...
}
})
.setPositiveButton(R.string.affirmative, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
...
}
})
.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});

return builder.create();
}

Buttons appear to be pushed off the screen

如果需要更多信息,请告诉我。

最佳答案

您是否碰巧使用 AlertDialog.BuildersetMessage() 方法来设置消息,尽管您的示例代码没有使用它?

因为如果您的内容不适合屏幕,同时向警报对话框构建器设置自定义 View 和消息会产生您所描述的副作用。

要解决此问题,请将消息添加到自定义 View 中,并且不要使用 setMessage() 方法设置消息文本,对话框按钮将可见。

希望这对您有所帮助。

关于android - DialogFragment 按钮推出屏幕 API 24 及更高版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44725164/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com