我正在关注this链接并使用这个完全相同的代码来制作这个流动的抽屉,但我正在使用eclipse并且在我的生活中我无法弄清楚问题。 我使用完全相同的代码,所以我不知道在这里发布什么。 我将在这里发布我的主要活动。在logcat中它崩溃在setcontentview上。我还会发布我的.xml文件
public class MainActivity extends AppCompatActivity {
private RecyclerView rvFeed;
private LeftDrawerLayout mLeftDrawerLayout;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
System.out.println("Calling Layout");
setContentView(R.layout.activity_main);
System.out.println("Layout Called");
setupToolbar();
mLeftDrawerLayout = (LeftDrawerLayout) findViewById(R.id.id_drawerlayout);
rvFeed = (RecyclerView) findViewById(R.id.rvFeed);
FragmentManager fm = getSupportFragmentManager();
MyMenuFragment mMenuFragment = (MyMenuFragment) fm.findFragmentById(R.id.id_container_menu);
FlowingView mFlowingView = (FlowingView) findViewById(R.id.sv);
if (mMenuFragment == null) {
fm.beginTransaction().add(R.id.id_container_menu, mMenuFragment = new MyMenuFragment()).commit();
}
mLeftDrawerLayout.setFluidView(mFlowingView);
mLeftDrawerLayout.setMenuFragment(mMenuFragment);
setupFeed();
}
protected void setupToolbar() {
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
toolbar.setNavigationIcon(R.drawable.ic_menu_white);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mLeftDrawerLayout.toggle();
}
});
}
private void setupFeed() {
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this) {
@Override
protected int getExtraLayoutSpace(RecyclerView.State state) {
return 300;
}
};
rvFeed.setLayoutManager(linearLayoutManager);
FeedAdapter feedAdapter = new FeedAdapter(this);
rvFeed.setAdapter(feedAdapter);
feedAdapter.updateItems();
}
@Override
public void onBackPressed() {
if (mLeftDrawerLayout.isShownMenu()) {
mLeftDrawerLayout.closeDrawer();
} else {
super.onBackPressed();
}
}
}
<com.abc.epicfloatinglibrary.LeftDrawerLayout
android:id="@+id/id_drawerlayout"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipChildren="false"
>
<!--content-->
<android.support.v7.design.widget.CoordinatorLayout
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:id="@+id/rvFeed"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<android.support.design.widget.AppBarLayout
android:id="@+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<include
android:id="@+id/toolbar"
layout="@layout/view_feed_toolbar" />
</android.support.design.widget.AppBarLayout>
<!--menu-->
<RelativeLayout
android:layout_width="280dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:clipChildren="false"
>
<com.abc.epicfloatinglibrary.FlowingView
android:id="@+id/sv"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<FrameLayout
android:id="@+id/id_container_menu"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_marginRight="25dp"
android:paddingRight="10dp"
/>
</RelativeLayout>
答案 0 :(得分:2)
请尝试以下操作。
如果您没有运行它,请检查您的build.gradle文件是否已将该库添加到依赖项中。