我已经看到底部对话框可以在没有底部行为的情况下工作。那么为什么需要使用它,因为我已经阅读了许多教程,它的书面、底部对话框和底部行为对于底部表来说是必须的。
我正在讨论模型底板。请找到以下代码:
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();
}
上面的代码运行良好。