Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid : BaseAdapter how to?
    text
    copied!<p>Ok, I have been searching thick and thin, and I am having some issues implementing a BaseAdapter.</p> <p>I have been able to implement a Simple Cursor Adapter <a href="http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/view/List7.html" rel="nofollow noreferrer">http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/view/List7.html</a> as per the example above.</p> <p>There is a pretty good BaseAdapter example here : <a href="http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/view/List14.html" rel="nofollow noreferrer">List14 google example</a></p> <p>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.</p> <p>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. : </p> <pre><code>@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; } </code></pre> <p>Do you have any good examples of a BaseAdapter being drawn using a cursor? </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload