[英]What is the role of Bottom Behavior in Bottom Sheet.
我已经看到底部对话框可以在没有底部行为的情况下工作。 那么为什么需要使用它,因为我已经阅读了许多教程,所以它的书面内容,底部对话框和底部行为必须用于底部表格。
我正在考虑模型底页。 请找到以下代码:
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();
}
上面的代码运行完美。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.