-2
我的應用程序有一個主屏幕,用戶可以點擊在主頁片段,這將打開導航抽屜一個可點擊的佈局,但我在使用的openDrawer(查看視圖)麻煩方法一旦佈局被點擊,讓抽屜打開。的Android:開放抽屜式導航欄上的佈局點擊
HomeFragment.java(其中可點擊佈局所在地)
public void onClick(View v) {
Toast toast = Toast.makeText(context, "Handle Drawer Opening Via This Event", Toast.LENGTH_LONG);
toast.show();
FragmentDrawer fragDrawer = new FragmentDrawer();
fragDrawer.openNavDrawer();
}
FragmentDrawer.java:
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflating view layout
View layout = inflater.inflate(R.layout.fragment_navigation_drawer, container, false);
recyclerView = (RecyclerView) layout.findViewById(R.id.drawerList);
adapter = new NavigationDrawerAdapter(getActivity(), getData());
recyclerView.setAdapter(adapter);
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
recyclerView.addOnItemTouchListener(new RecyclerTouchListener(getActivity(), recyclerView, new ClickListener() {
@Override
public void onClick(View view, int position) {
drawerListener.onDrawerItemSelected(view, position);
mDrawerLayout.closeDrawer(containerView);
}
@Override
public void onLongClick(View view, int position) {
}
}));
return layout;
}
//This method is called from the click event in HomeFragment.java
public void openNavDrawer(){
mDrawerLayout.openDrawer(Gravity.START);
}
什麼樣的錯誤你有沒有遇到過? –