【发布时间】:2017-11-23 20:59:39
【问题描述】:
我搜索了很多,但找不到任何解决方案 和 Snackbar is not working within fragment class 没有帮助。我传递了片段的 rootView 并尝试从 getActivity 传递一个视图,但它们都不起作用!
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
rootView = inflater.inflate(R.layout.content_dialog_bottom_sheet, container, false);
Snackbar.make(MyActivity.myTextview, "Hello", Snackbar.LENGTH_INDEFINITE).show();
Snackbar.make(rootView, "Hello", Snackbar.LENGTH_INDEFINITE).show();
return rootView;
}
还有我的 content_dialog_bottom_sheet :
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/bottomSheetLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/background"
app:behavior_hideable="true"
app:behavior_peekHeight="180dp"
app:layout_behavior="@string/bottom_sheet_behavior">
//some views
</RelativeLayout>
【问题讨论】:
-
请添加一些代码
-
@ImAtWar 我添加了
-
请显示您的布局文件代码。
-
如果它仍然是实际的https://stackoverflow.com/a/34477987/4486007 帮助。
标签: android android-fragments bottom-sheet android-snackbar