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 things up for me and tell me how to use it with my method above i'd be really greatful!

Answers


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));

Need Your Help

How do you migrate an existing core data iOS 7 app's data into iCloud?

ios core-data ios7 icloud

I have an iOS 7 app that already uses Core Data. I have used the new iOS 7 method of integrating iCloud into my app to sync items stored in core data by using the following code as an example:

How to preselect contenteditable field in UIWebView iOS5

javascript uiwebview ios5 contenteditable

First of all I know contenteditable is only iOS 5 I have accounted for this - we are giving users with iOS 5 a feature to allow Rich Text pasting using contenteditable. This feature works great so ...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.