Diolor/Swipecards

Getting a crash

Closed this issue · 3 comments

I am using a custom layout.
I tried using frame layout and linear layout as the root view
also tried match_parent and some constant number with the width and height.. for the root view. but the crash still occurs

java.lang.NullPointerException: Attempt to read from field 'int android.view.ViewGroup$MarginLayoutParams.leftMargin' on a null object reference
at com.lorentzos.flingswipe.SwipeFlingAdapterView.makeAndAddView(SwipeFlingAdapterView.java:149)
at com.lorentzos.flingswipe.SwipeFlingAdapterView.layoutChildren(SwipeFlingAdapterView.java:132)
at com.lorentzos.flingswipe.SwipeFlingAdapterView.onLayout(SwipeFlingAdapterView.java:117)

Figured it out. It was due to a silly bug that i had in the array adapter on bindview method.

Could you elaborate on the bug? I have the same error.

public View getView(final int position, View convertView, ViewGroup parent) {
        View itemView = convertView;
        if (itemView == null) {
            LayoutInflater layoutInflater = (LayoutInflater) context
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        //Earlier I was using this code. Later replaced it with the code below : itemView = layoutInflater.inflate(R.layout.item_group_match_request, null);
            itemView = layoutInflater.inflate(R.layout.item_group_match_request, parent, false);
        }
      ...........
      ...........
        return itemView;
    }