开发者

How should I be using .setAdapter here? /How do i get around not extending ListActivity?

I have a class that is already extending TabActivity so i can't extend ListActivity.

This hasn't be a problem until i needed to use this method:

private static int[] TO = { R.id.catItem, R.id.budgetAmount, };
private void showBudgetOutcome(Cursor cursor) {
//Set up data binding 
SimpleCursorAdapter adapter = new SimpleCursorAdapter(
this, R.layout.itemsforbudgetlist, cursor, FROM, TO);
setListAdapter(adapter);

}

Obviously setListAdapter is undefined. Now i found this snippet of code searching SO

mListView.setAdapter(new ArrayAdapter<String>(this, R.layout.list_item, COUNTRIES));

But i don't really understand the parameters. I tried altering it to suit me:

incomeView.setAdapter(new SimpleCursorAdapter<String>(this, R.layout.itemsforbudgetlist, adapter??));

I see that mListView is just the users ListView so i replaced that, and the layout resource defining how each item in the list looks i guess. But the rest i'm not sure about. I figure maybe i want a Simple/CursorAdapter since i'm working with sqlite (see my method)? but i have no idea what COUNTRIES is meant to be and not sure what data type i need (presumably string but what do i know). So if someone could clear thin开发者_如何学Pythongs up for me and tell me how to use it with my method above i'd be really greatful!


If you want to pull your data from a database you need to subclass CursorAdapter. Then you can just call:

incomeView.setAdapter(new MyCursorAdapter(WhatEver arguments, You need));
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜