Diolor / Swipecards

A Tinder-like Android library to create the swipe cards effect. You can swipe left or right to like or dislike the content.
Apache License 2.0
2.34k stars 583 forks source link

Getting a crash #198

Closed saurabhdtu closed 7 years ago

saurabhdtu commented 7 years ago

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)

saurabhdtu commented 7 years ago

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

inlacou commented 7 years ago

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

saurabhdtu commented 7 years ago
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;
    }