我看到底部对话框可以在没有底层行为的情况下工作。然后为什么它需要被使用,因为我已经阅读了很多教程,它的书面,底部对话和底部行为都是底页。
我正在拍模型底页。 请找到以下代码:
private void createDialog() {
if (dismissDialog()) {
return;
}
List<SampleModel> list = new ArrayList<>();
list.add(new SampleModel(R.string.share, R.mipmap.ic_launcher));
list.add(new SampleModel(R.string.upload, R.mipmap.ic_launcher));
list.add(new SampleModel(R.string.copy, R.mipmap.ic_launcher));
list.add(new SampleModel(R.string.print, R.mipmap.ic_launcher));
SampleSheetAdapter adapter = new SampleSheetAdapter(list);
adapter.setOnItemClickListener(new SampleSheetAdapter.OnItemClickListener() {
@Override
public void onItemClick(SampleSheetAdapter.ItemHolder item, int position) {
Toast.makeText(mContext,"clicked",Toast.LENGTH_LONG).show();
}
});
View view = getLayoutInflater().inflate(R.layout.sheet_main, null);
RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.recyclerView);
recyclerView.setHasFixedSize(true);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
recyclerView.setAdapter(adapter);
dialog = new BottomSheetDialog(this);
dialog.setContentView(view);
dialog.show();
}
上面的代码工作正常。