listview problem

Put your problem here if it does not fit any of the other categories.

listview problem

Postby amita » Fri Jul 19, 2013 5:49 am


public class ListViewLoader extends ListActivity
implements LoaderManager.LoaderCallbacks<Cursor> {

SimpleCursorAdapter mAdapter;
static final String[] PROJECTION = new String[] {ContactsContract.Data._ID,
ContactsContract.Data.DISPLAY_NAME}
static final String SELECTION = "((" +
ContactsContract.Data.DISPLAY_NAME + " NOTNULL) AND (" +
ContactsContract.Data.DISPLAY_NAME + " != '' ))";

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

ProgressBar progressBar = new ProgressBar(this);
progressBar.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT, Gravity.CENTER));
progressBar.setIndeterminate(true);
getListView().setEmptyView(progressBar);
ViewGroup root = (ViewGroup) findViewById(android.R.id.content);
root.addView(progressBar);

String[] fromColumns = {ContactsContract.Data.DISPLAY_NAME};
int[] toViews = {android.R.id.text1}; // The TextView in simple_list_item_1
//always problem occurre in this line that fromColumns cant not be resolved to variable how can i overcome from this problem
mAdapter = new SimpleCursorAdapter(this,
android.R.layout.simple_list_item_1, null,
fromColumns, toViews, 0);
setListAdapter(mAdapter);
getLoaderManager().initLoader(0, null, this);
}
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
return new CursorLoader(this, ContactsContract.Data.CONTENT_URI,
PROJECTION, SELECTION, null, null);
}
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
mAdapter.swapCursor(data);
}
public void onLoaderReset(Loader<Cursor> loader) {
mAdapter.swapCursor(null);
}

@Override
public void onListItemClick(ListView l, View v, int position, long id) {
}
}
amita
Freshman
Freshman
 
Posts: 2
Joined: Thu Jul 18, 2013 11:13 am

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 19 guests