Ok, I have been searching thick and thin, and I am having some issues implementing a BaseAdapter.
I have been able to implement a Simple Cursor Adapter http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/view/List7.html as per the example above.
There is a pretty good BaseAdapter example here : List14 google example
I am wanting to create my own List Adapter using BaseAdapter to show a listView, with multiple items from a Database. I know this can be done using the Simple Cursor Adapter, but I am looking to handle rows differently, so I want to be able to draw each row by overriding getView. The data would be pulled from a cursor.
I know this code is ugly for getting to the cursor data, but assuming I have populated a cursor. What suggestions do you have on this if column 8 contains the image resource id. :
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
cursor.moveToPosition(position);
ImageView i = new ImageView(mContext);
i.setImageResource(cursor.getShort(8));
i.setAdjustViewBounds(true);
i.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
return i;
}
Do you have any good examples of a BaseAdapter being drawn using a cursor?
Try calling notifyDataSetChanged() from a method inside the BaseAdapter itself.
See the methods in List8 of the API Demos as an example.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With