Listview with multiple row layout
<p>Hi below is my class for baseadapter, but it is not working !!</p>

<p>i try to use ListView with multiple Row, I did not understand where I was wrong
first layout contains just textView and the second contains textview and imageView</p>

<pre><code>public class CustomAdapter extends BaseAdapter {

public static final int TYPE_ODD = 0;
public static final int TYPE_EVEN = 1;




private Context context;
private List&lt;ItemSlideMenu&gt; lstItem;
@Override
public int getViewTypeCount() {
    return 2;
}

@Override
public int getItemViewType(int position) {
    return lstItem.get(position).getType();
}


public CustomAdapter(Context context, List&lt;ItemSlideMenu&gt; lstItem) {
    this.context = context;
    this.lstItem = lstItem;
}

@Override
public int getCount() {
    return lstItem.size();
}

@Override
public Object getItem(int position) {
    return lstItem.get(position);
}

@Override
public long getItemId(int position) {
    return position;
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {

    int listViewItemType = getItemViewType(position);

    if (convertView == null) {

        if (listViewItemType == TYPE_EVEN) {
            convertView = View.inflate(context, R.layout.item_sliding_menu, null);
            ImageView img = (ImageView) convertView.findViewById(R.id.item_img);
            TextView tv = (TextView) convertView.findViewById(R.id.item_title);

            ItemSlideMenu item = lstItem.get(position);
            img.setImageResource(item.getImgId());
            tv.setText(item.getTitle());

        }

        else if (listViewItemType == TYPE_ODD) {
            convertView = View.inflate(context, R.layout.reseaux, null);
            ImageView img = (ImageView) convertView.findViewById(R.id.item_img);
            TextView tv = (TextView) convertView.findViewById(R.id.item_title);

            ItemSlideMenu item = lstItem.get(position);
            img.setImageResource(item.getImgId());
            tv.setText(item.getTitle());

        }


    }

return convertView ;

}}
</code></pre>

<p>i have an error</p>

<pre><code> 05-27 16:05:45.297 25537-25537/com.example.getgpslocation E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.getgpslocation, PID: 25537
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ImageView.setImageResource(int)' on a null object reference
</code></pre>

<p>Fragment3.java </p>

<pre><code> listSliding3 = new ArrayList&lt;&gt;();
    //Add item for sliding list
    listSliding3.add(new ItemSlideMenu("TRAM " , CustomAdapter.TYPE_ODD));
    listSliding3.add(new ItemSlideMenu(R.drawable.ic_action_about,"Ligne1",CustomAdapter.TYPE_EVEN ));
    listSliding3.add(new ItemSlideMenu(R.drawable.ic_action_about,"Ligne2",CustomAdapter.TYPE_EVEN ));
    listSliding3.add(new ItemSlideMenu("BUS " , CustomAdapter.TYPE_ODD));


    CustomAdapter customAdapter = new CustomAdapter(getActivity(),listSliding3);
    listViewSliding3.setAdapter(customAdapter);
</code></pre>