List of usage examples for android.widget SimpleCursorAdapter SimpleCursorAdapter
@Deprecated public SimpleCursorAdapter(Context context, int layout, Cursor c, String[] from, int[] to)
From source file:org.kontalk.ui.StatusFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mAdapter = new SimpleCursorAdapter(getActivity(), android.R.layout.simple_list_item_1, null, new String[] { "status" }, new int[] { android.R.id.text1 }); setListAdapter(mAdapter);//from ww w . j ava 2 s.c o m }
From source file:com.commonsware.cwac.loaderex.demo.ConstantsBrowserACL.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectAll().penaltyLog().build()); StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectLeakedSqlLiteObjects() .detectLeakedClosableObjects().penaltyLog().penaltyDeath().build()); setContentView(R.layout.main);/*from w w w . j av a 2s . c om*/ db = new DatabaseHelper(this); adapter = new SimpleCursorAdapter(this, R.layout.row, null, new String[] { DatabaseHelper.TITLE, DatabaseHelper.VALUE }, new int[] { R.id.title, R.id.value }); ListView lv = (ListView) findViewById(R.id.constants); lv.setAdapter(adapter); registerForContextMenu(lv); getSupportLoaderManager().initLoader(0, null, this); }
From source file:com.example.edwin.car2charge.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setTitle(R.string.app_name);/* w w w .j a va 2s. co m*/ if (ContextCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ContextCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { requestPermissions(new String[] { android.Manifest.permission.ACCESS_FINE_LOCATION }, 1); } if (!isNetworkConnected()) { Toast.makeText(getApplicationContext(), "Sorry, no internet connection", Toast.LENGTH_LONG).show(); } else { //Toast.makeText(getApplicationContext(), "Yes! network", Toast.LENGTH_LONG).show(); getContentResolver().delete(CarDataProvider.CONTENT_URI, null, null); String[] projection = { CarDatabase.C_ID, CarDatabase.C_ADDRESS, CarDatabase.C_LICENSE, CarDatabase.C_BATTERY, CarDatabase.C_DISTANCE, CarDatabase.C_DISTANCE_CP }; Cursor cars = getContentResolver().query(CarDataProvider.CONTENT_URI, projection, null, null, null); SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, R.layout.row, cars, FROM, TO); adapter.setViewBinder(VIEW_BINDER); setListAdapter(adapter); carDownloadIntent = new Intent(getApplicationContext(), CarDownloaderService.class); gps = new GpsTracker(this, this); gps.getLocation(); } }
From source file:com.tmm.android.twitter.ContactManager.java
/** * Populate the contact list based on account currently selected in the account spinner. *//*w w w.j a va 2s . c om*/ private void populateContactList() { // Build adapter with contact entries Cursor cursor = getContacts(); String[] fields = new String[] { ContactsContract.Data.DISPLAY_NAME }; SimpleCursorAdapter adapter = new SimpleCursorAdapter(getActivity(), R.layout.contact_entry, cursor, fields, new int[] { R.id.contactEntryText }); mContactList.setAdapter(adapter); }
From source file:com.facebook.samples.rps.FriendActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.friends_activity); FragmentManager fragmentManager = getSupportFragmentManager(); friendPickerFragment = (FriendPickerFragment) fragmentManager.findFragmentById(R.id.friend_fragment); friendPickerFragment.setShowTitleBar(false); ListView friendActivityList = (ListView) findViewById(R.id.friend_activity_list); String[] mapColumnNames = { "date", "action" }; int[] mapViewIds = { R.id.friend_action_date, R.id.friend_game_result }; friendActivityAdapter = new SimpleCursorAdapter(this, R.layout.friend_activity_row, createEmptyCursor(), mapColumnNames, mapViewIds); friendActivityList.setAdapter(friendActivityAdapter); friendActivityProgressBar = (ProgressBar) findViewById(R.id.friend_activity_progress_bar); friendPickerFragment.setOnErrorListener(new PickerFragment.OnErrorListener() { @Override//from ww w . j a v a 2s .co m public void onError(PickerFragment<?> fragment, FacebookException error) { FriendActivity.this.onError(error); } }); friendPickerFragment.setUserId("me"); friendPickerFragment.setMultiSelect(false); friendPickerFragment.setOnSelectionChangedListener(new PickerFragment.OnSelectionChangedListener() { @Override public void onSelectionChanged(PickerFragment<?> fragment) { FriendActivity.this.onFriendSelectionChanged(); } }); friendPickerFragment.setExtraFields(Arrays.asList(INSTALLED)); friendPickerFragment.setFilter(new PickerFragment.GraphObjectFilter<GraphUser>() { @Override public boolean includeItem(GraphUser graphObject) { Boolean installed = graphObject.cast(GraphUserWithInstalled.class).getInstalled(); return (installed != null) && installed.booleanValue(); } }); Button inviteButton = (Button) findViewById(R.id.invite_button); inviteButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { WebDialog.RequestsDialogBuilder builder = new WebDialog.RequestsDialogBuilder(FriendActivity.this, Session.getActiveSession()).setTitle(getString(R.string.invite_dialog_title)) .setMessage(getString(R.string.invite_dialog_message)) .setOnCompleteListener(new WebDialog.OnCompleteListener() { @Override public void onComplete(Bundle values, FacebookException error) { if (error != null) { Log.w(TAG, "Web dialog encountered an error.", error); } else { Log.i(TAG, "Web dialog complete: " + values); } } }); if (friendId != null) { builder.setTo(friendId); } builder.build().show(); } }); }
From source file:com.example.android.notepad.NotesList.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setDefaultKeyMode(DEFAULT_KEYS_SHORTCUT); // If no data was given in the intent (because we were started // as a MAIN activity), then use our default content provider. Intent intent = getIntent();/*from w w w. ja va2 s. co m*/ if (intent.getData() == null) { intent.setData(Notes.CONTENT_URI); } // Inform the list we provide context menus for items getListView().setOnCreateContextMenuListener(this); // Perform a managed query. The Activity will handle closing and requerying the cursor // when needed. Cursor cursor = managedQuery(getIntent().getData(), PROJECTION, null, null, Notes.DEFAULT_SORT_ORDER); // Used to map notes entries from the database to views SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, R.layout.noteslist_item, cursor, new String[] { Notes.TITLE }, new int[] { android.R.id.text1 }); setListAdapter(adapter); }
From source file:com.google.android.demos.rss.app.ChannelActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); setContentView(R.layout.list_activity); ListView listView = (ListView) findViewById(android.R.id.list); mEmpty = findViewById(R.id.empty);/*w w w. j a v a2 s . c o m*/ mLoading = findViewById(R.id.loading); mError = findViewById(R.id.error); mError.findViewById(R.id.retry).setOnClickListener(this); // Loader from last Activity instance may still be loading mLoading.setVisibility(View.VISIBLE); mEmpty.setVisibility(View.GONE); mError.setVisibility(View.GONE); Context context = this; int layout = android.R.layout.simple_list_item_1; String[] from = { Items.TITLE }; int[] to = { android.R.id.text1 }; SimpleCursorAdapter innerAdapter = new SimpleCursorAdapter(context, layout, null, from, to); innerAdapter.setViewBinder(this); mAdapter = new ChannelAdapter(this); mAdapter.registerDataSetObserver(new TitleObserver()); listView.setAdapter(mAdapter); listView.setOnItemClickListener(this); getSupportLoaderManager().initLoader(LOADER_CHANNEL, Bundle.EMPTY, this); }
From source file:de.greenrobot.daoexample.NoteActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main);//from w w w .j a v a 2s . co m DevOpenHelper helper = new DaoMaster.DevOpenHelper(this, "notes-db", null); db = helper.getWritableDatabase(); daoMaster = new DaoMaster(db); daoSession = daoMaster.newSession(); noteDao = daoSession.getNoteDao(); playHistoryDao = daoSession.getPlayHistoryDao(); sw = new StopWatch(); String textColumn = NoteDao.Properties.Text.columnName; String orderBy = textColumn + " COLLATE LOCALIZED ASC"; cursor = db.query(noteDao.getTablename(), noteDao.getAllColumns(), null, null, null, null, orderBy); String[] from = { textColumn, NoteDao.Properties.Comment.columnName }; int[] to = { android.R.id.text1, android.R.id.text2 }; SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, android.R.layout.simple_list_item_2, cursor, from, to); setListAdapter(adapter); editText = (EditText) findViewById(R.id.editTextNote); initView(); addUiListeners(); }
From source file:org.barbon.mangaget.fragments.MangaList.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); adapter = new SimpleCursorAdapter(getActivity(), R.layout.manga_item, null, new String[] { DB.MANGA_TITLE, DB.ID, DB.MANGA_URL }, new int[] { R.id.manga_title, R.id.manga_progress, R.id.manga_provider }); adapter.setViewBinder(viewBinder);/*from w ww . j a v a 2 s .c o m*/ }
From source file:it.imwatch.nfclottery.dialogs.WinnersListDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { // Use the Builder class for convenient dialog construction final Activity activity = getActivity(); if (activity == null) { Log.e(TAG, "Not attached to Activity: cannot build dialog"); return null; }/*from w ww .ja v a 2 s . c o m*/ AlertDialog.Builder builder = new AlertDialog.Builder(activity); mWinnersCursor = updateWinnersCursors(); String[] inVal = new String[] { NFCMLContent.Geeks.Columns.NAME.getName(), NFCMLContent.Geeks.Columns.EMAIL.getName() }; int[] outVal = new int[] { R.id.txt_name, R.id.txt_email }; // Create the adapter and assign it to the list mWinnersAdapter = new SimpleCursorAdapter(getActivity(), R.layout.winners_row, mWinnersCursor, inVal, outVal); mWinnersAdapter.setViewBinder(new ContactsViewBinder()); LayoutInflater inflater = LayoutInflater.from(activity); final View rootView = inflater.inflate(R.layout.winners_dialog_layout, null); if (rootView == null) { Log.e(TAG, "Cannot inflate the dialog layout!"); return null; } ListView listView = (ListView) rootView.findViewById(R.id.list_winners); listView.setAdapter(mWinnersAdapter); listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { showRevokeVictoryUi(position); return true; } }); TextView emptyTxt = (TextView) rootView.findViewById(android.R.id.empty); emptyTxt.setOnClickListener(mClickListener); listView.setEmptyView(emptyTxt); builder.setView(rootView); mSwitcher = (ViewSwitcher) rootView.findViewById(R.id.switcher); Button btn_cancel = (Button) mSwitcher.findViewById(R.id.btn_cancel); btn_cancel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { endRevokeVictory(); } }); Button btn_revoke = (Button) mSwitcher.findViewById(R.id.btn_revoke); btn_revoke.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { revokeVictory(); } }); Button btn_ok = (Button) mSwitcher.findViewById(android.R.id.button1); btn_ok.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { final Dialog thisDialog = WinnersListDialog.this.getDialog(); if (thisDialog != null) { thisDialog.cancel(); } else { Log.w(TAG, "Can't get the Dialog instance."); } } }); // Create the AlertDialog object and return it return builder.create(); }