I have to load data from the cursor to listview in my app. Here is my custom adapter class. And it works fine. But I need to show a separate layout for very first row of the listview. The first row in list will have an extra imageview. How can I do so? Please help me. Thanks in advance.
public class CustomSCAdapter extends SimpleCursorAdapter {
Cursor c;
Context context;
Activity activity;
int layout;
public CustomSCAdapter(Context context, int layout, Cursor c, String[] from, int[] to, int flags ) {
super(context, layout, c, from, to, flags);
this.c = c;
this.context=context;
this.activity=(Activity) context;
this.layout = layout;
}
@Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
final View view = LayoutInflater.from(context).inflate(this.layout, parent, false);
return view;
}
@Override
public void bindView(View view, Context context, Cursor cursor) {
//here finding all my views in row from view object and binding data from cursor as per my requirement.
}
}
EDIT : Actually i'am passing null for cursor variable for constructor of adapter class as i'am using loaders mechanism in my fragment.
getLoaderManager().initLoader(0, null, this);
adapter = new CustomSCAdapter(getActivity(), R.layout.row_layout, null, from, to, 0);