我正面临BottomSheetDialogFragment
的问题。我在Spinner
使用了BottomSheetDialogFragment
,用于BottomSheet我正在使用
'com.android.support:design:23.2.0'
依赖。
现在问题在于Spinner
,当我从spinner中选择项时,它仍然是spinner前面的默认值,即使onItemSelected
没有调用。
但是当我删除这一行时mBehavior.setState(BottomSheetBehavior.STATE_EXPANDED)
Spinner工作正常,但是在更改了微调器BottomSheet
的项目之后拖动了一下,所以我必须再次将它向上拖动。
我尝试com.android.support:design:25.2.0
25.2.0
一切正常,但我希望它与23
一起正常使用,因为我的整个项目仅使用23.2.0
下面是我的BottomSheetDialogFragment代码
public void setupDialog(Dialog dialog, int style)
{
super.setupDialog(dialog, style);
mBottomSheetView = View.inflate(getContext(), R.layout.abc_layout, null);
dialog.setContentView(mBottomSheetView);
dialog.setCanceledOnTouchOutside(false);
dialog.setOnShowListener(new DialogInterface.OnShowListener() {
@Override
public void onShow(DialogInterface dialogInterface)
{
BottomSheetDialog bottomSheetDialog = (BottomSheetDialog) dialogInterface;
FrameLayout frameLayout = (FrameLayout) bottomSheetDialog.findViewById(android.support.design.R.id.design_bottom_sheet);
mBehavior = BottomSheetBehavior.from(frameLayout);
mBehavior.setHideable(false);
mBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
}
});
mTermAdapter = new TermSpinnerAdapter(getContext(), mTermList);
mTermSpinner.setAdapter(mTermAdapter);
mTermSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id)
{
Log.i(TAG, "onItemSelected: ");
}
@Override
public void onNothingSelected(AdapterView<?> parent)
{
}
});
mAssessmentSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id)
{
Log.i(TAG, "onItemSelected: ");
}
@Override
public void onNothingSelected(AdapterView<?> parent)
{
}
});
}