Android Studio DrawerLayout won’t open

Home / Uncategorized / Android Studio DrawerLayout won’t open

Question:
I am unable open my drawerlayout by dragging once I add the code below to my swipe_layout.xml



If i remove it then i can open my drawer layout. I did some test runs to see what the problem could be. So far I’ve realized that no gestures are being recognized at all once i add that code. (Taps, Swipes, onClicks nothing) So maybe somewhere in that library it removes gesture recognizing? IDK! I got the library from here everything works fine other than that issue.

this is the Gradle

compile ‘com.wajahatkarim3.EasyFlipView:EasyFlipView:1.0.2’

thank you for the help in advance. Once i get this I can move on to making the best app out there 😉

All Code Below

swipe_layout.xml



flash_card_layout_back.xml

flash_card_layout_front.xml

savedImagesViewController.java
public class savedImagesViewController extends AppCompatActivity {

ViewPager viewPager;
customSwipeAdapter adapter;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_saved_images_view_controller);

viewPager = (ViewPager) findViewById(R.id.view_pager);
adapter = new customSwipeAdapter(this);
viewPager.setAdapter(adapter);
viewPager.setPageTransformer(false, new DefaultTransformer());
}

customSwipeAdapter.java
public class customSwipeAdapter extends PagerAdapter {

private int[] frontImages = {R.drawable.image1, R.drawable.image2, R.drawable.image3};

private Context ctx;
private LayoutInflater layoutInflator;

public customSwipeAdapter(Context ctx) {
this.ctx = ctx;
}

@Override
public int getCount() {
return frontImages.length;
}

@Override
public boolean isViewFromObject(View view, Object o) {
return (view == (RelativeLayout)o);
}

@Override
public Object instantiateItem(ViewGroup container, int position) {
final EasyFlipView mYourFlipView = (EasyFlipView) item_view.findViewById(R.id.flipView);
ImageView imageView_Front = (ImageView) item_view.findViewById(R.id.imageView_Front);
ImageView imageView_Back = (ImageView) item_view.findViewById(R.id.imageView_Back);

layoutInflator = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

final View item_view = layoutInflator.inflate(R.layout.swipe_layout, container, false);

imageView_Front.setImageResource(frontImages[position]);

container.addView(item_view);

return item_view;
}

@Override
public void destroyItem(ViewGroup container, int position, Object object) {
container.removeView((RelativeLayout)object);
}
}


Answer:
Try this hope it was helpful for you
Make "Header layout" in which, what you want to like image and text.(prepare a custom menu-drawer)







Then make another layout for drawer-menu. This is Parent_main

















Make Class For** navigation Adapter**

public class NavigationDrawerAdapter extends
RecyclerView.Adapter {
private LayoutInflater inflater;
private List> focusHeader;
private Context context;
public static boolean
Snackbar snackbar;
String[] name={
"About Focus",
"FAQ",
"Help"};
Integer[] image_ID={
R.drawable.logo,
R.drawable.faq,
R.drawable.help,};
Intent intent;
public NavigationDrawerAdapter(List>
focusHeader,Context context) {
this.focusHeader=focusHeader;
this.context = context;
inflater = LayoutInflater.from(context);}
@Override
public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = inflater.inflate(R.layout.nav_drawer_row, parent, false);
MyViewHolder holder = new MyViewHolder(view);
return holder;
}
@Override
public void onBindViewHolder(MyViewHolder holder, final int position) {
holder.tv_subTitle.setText(name[position]);
holder.iv_drawerIcon.setImageResource(image_ID[position]);
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {

else if (name[position].equals("About Focus")){

}
else if (name[position].equals("FAQ")){

}
else if (name[position].equals("Help")){

}

});
}

@Override
public int getItemCount() {
return name.length;
}

class MyViewHolder extends RecyclerView.ViewHolder {
TextView tv_title,tv_subTitle;
ImageView iv_drawerIcon;

public MyViewHolder(View itemView) {
super(itemView);
iv_drawerIcon=itemView.findViewById(R.id.iv_drawerIcon);
tv_subTitle=itemView.findViewById(R.id.tv_subTitle);
}
}

Make a layout for nav_drawer_row




Use this Class AS Parent_main

public class TabActivityClass extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.parent_main);
RecyclerView.LayoutManager mLayoutManager = new
LinearLayoutManager(getApplicationContext());
rv_navigation.setLayoutManager(mLayoutManager);
rv_navigation.setItemAnimator(new DefaultItemAnimator());
rv_navigation.setAdapter(new NavigationDrawerAdapter(new
ArrayList>(),parent_main.this));
drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
this, drawer, toolbar, R.string.navigation_drawer_open,
R.string.navigation_drawer_close);
drawer.addDrawerListener(toggle);
toggle.setDrawerIndicatorEnabled(false);
toggle.syncState();
}
}

enter image description here
Read more

Leave a Reply

Your email address will not be published. Required fields are marked *