Android : BaseAdapter how to?

Try calling notifyDataSetChanged() from a method inside the BaseAdapter itself See the methods in List8 of the API Demos as an example.

Try calling notifyDataSetChanged() from a method inside the BaseAdapter itself. See the methods in List8 of the API Demos as an example.

On a delete, I want it to rebuild. Chris. Public void onCreate(Bundle bundle) { super.

OnCreate(bundle); //setContentView(R.layout. Findlist); //getListView(). SetEmptyView(findViewById(R.id.

Empty)); mDbHelper = new DBHelper(this); mDbHelper.open(); cursor = mDbHelper. FetchAllLocations(); startManagingCursor(cursor); mAdapter = new myListAdapter(this); setListAdapter(mAdapter); } public class myListAdapter extends BaseAdapter { public myListAdapter(Context c) { ... public int getCount() { ... public Object getItem(int position) { ... public long getItemId(int position) { ... @Override public View getView(int position, View convertView, ViewGroup parent) { cursor. MoveToPosition(position); RowView rv; if (convertView == null) { rv = new RowView(mContext,(cursor.

GetString(2)), (cursor. GetString(5)), position); } else { rv = (RowView) convertView; rv. SetTitle(cursor.

GetString(2)); rv. SetDialogue(cursor. GetString(5)); rv.

SetFocusable(true); rv. SetClickable(true); } return rv; } } @Override protected void onListItemClick(ListView l, View v, int position, long id) { // TODO Auto-generated method stub super. OnListItemClick(l, v, position, id); // Do what you will need to w/ a List Row Click Intent h = new Intent(FindList.

This,showmaplocation. Class); startActivityForResult(h,SAVE_TABS); } private class RowView extends LinearLayout { public RowView(Context context, String title, String words, int position) { super(context); this. SetOrientation(VERTICAL); // Here we build the child views in code.

They could also have // been specified in an XML file. MTitle = new TextView(context); mTitle. SetText(title); addView(mTitle, new LinearLayout.

LayoutParams( LayoutParams. FILL_PARENT, LayoutParams. WRAP_CONTENT)); mDialogue = new TextView(context); mDialogue.

SetText(words); addView(mDialogue, new LinearLayout. LayoutParams( LayoutParams. FILL_PARENT, LayoutParams.

WRAP_CONTENT)); Button mButton = new Button(context); mButton. SetFocusable(false); mButton. SetId(position); addView(mButton, new LinearLayout.

LayoutParams( LayoutParams. WRAP_CONTENT, LayoutParams. WRAP_CONTENT)); currentPosition = position; Button button = (Button)findViewById(position); button.

SetOnClickListener(mDeleteListener); } private OnClickListener mDeleteListener = new OnClickListener() { public void onClick(View v) { // To send a result, simply call setResult() before your // activity is finished, building an Intent with the data // you wish to send. Intent data = new Intent(); data. SetAction("Corky!

"); setResult(RESULT_OK, data); // finish(); cursor. MoveToPosition(v.getId()); mDbHelper. DeleteLocation(cursor.

GetInt(0)); // mAdapter.remove() mAdapter. NotifyDataSetChanged(); setListAdapter(mAdapter); Toast mToast; mToast = Toast. MakeText(FindList.

This, "Deleted" , Toast. LENGTH_LONG); mToast.show(); } }; /** * Convenience method to set the title of a SpeechView */ public void setTitle(String title) { mTitle. SetText(title); } /** * Convenience method to set the dialogue of a SpeechView */ public void setDialogue(String words) { mDialogue.

SetText(words); } private TextView mTitle; private TextView mDialogue; } }.

Ok, I have been searching thick and thin, and I am having some issues implementing a BaseAdapter. http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/view/List7.html as per the example above. 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 cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions