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:info.guardianproject.otr.app.im.app.NewChatActivity.java
private void setupAccountSpinner(Spinner spinner) { final Uri uri = Imps.Provider.CONTENT_URI_WITH_ACCOUNT; final Cursor cursorProviders = managedQuery(uri, PROVIDER_PROJECTION, Imps.Provider.CATEGORY + "=?" + " AND " + Imps.Provider.ACTIVE_ACCOUNT_USERNAME + " NOT NULL" /* selection */, new String[] { ImApp.IMPS_CATEGORY } /* selection args */, Imps.Provider.DEFAULT_SORT_ORDER); SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, android.R.layout.simple_spinner_dropdown_item, cursorProviders, new String[] { Imps.Provider.ACTIVE_ACCOUNT_USERNAME }, new int[] { android.R.id.text1 }); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); if (cursorProviders.getCount() > 0) { cursorProviders.moveToFirst();//from www . j av a 2 s .c o m mLastProviderId = cursorProviders.getLong(PROVIDER_ID_COLUMN); mLastAccountId = cursorProviders.getLong(ACTIVE_ACCOUNT_ID_COLUMN); spinner.setAdapter(adapter); spinner.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) { cursorProviders.moveToPosition(arg2); mLastProviderId = cursorProviders.getLong(PROVIDER_ID_COLUMN); mLastAccountId = cursorProviders.getLong(ACTIVE_ACCOUNT_ID_COLUMN); } @Override public void onNothingSelected(AdapterView<?> arg0) { // TODO Auto-generated method stub } }); } else { spinner.setVisibility(View.GONE); } }
From source file:com.example.android.lightcontrol.MainActivity.java
public void updatespinner() { //DB?UserGroupSpinner? helper = new DBHelper(getApplicationContext()); cursor = helper.select(TABLE_NAME_DALISLAVEADDRESS); if (cursor.getCount() > 0) { Spinner spinner = (Spinner) findViewById(R.id.mySpinner); cursor.moveToFirst();/* ww w . j av a2 s. c o m*/ SimpleCursorAdapter adapter = new SimpleCursorAdapter(MainActivity.this, R.layout.message, cursor, new String[] { "_dali_name" }, new int[] { R.id.message }); spinner.setAdapter(adapter); spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { helper = new DBHelper(getApplicationContext()); cursor = helper.select(TABLE_NAME_DALISLAVEADDRESS); cursor.moveToPosition(i); if (cursor.getString(1) != null) { GlobalVariable.OnSpinnerItemSelected = cursor.getString(1); //if (cursor.getString(2)!=null){ //GlobalVariable.OnSpinnerItemSelectedOfShort = cursor.getString(2);} // if (D) // Log.e(TAG, "GlobalVariable.OnSpinnerItemSelected = : " + GlobalVariable.OnSpinnerItemSelected); } } @Override public void onNothingSelected(AdapterView<?> adapterView) { } }); } }
From source file:ua.mkh.settings.full.MainActivity.java
private void showResults(String query) { Cursor cursor;//from ww w .java2 s . c o m String d = Locale.getDefault().getLanguage(); if (d.contains("ru")) { cursor = mDbHelper.searchCustomer_ru((query != null ? query.toString() : "@@@@")); } else if (d.contains("uk")) { cursor = mDbHelper.searchCustomer_uk((query != null ? query.toString() : "@@@@")); } else { cursor = mDbHelper.searchCustomer_ru((query != null ? query.toString() : "@@@@")); } if (cursor == null) { // } else { // Specify the columns we want to display in the result String[] from = new String[] { CustomersDbAdapter.KEY_CUSTOMER, CustomersDbAdapter.KEY_NAME, CustomersDbAdapter.KEY_ADDRESS, CustomersDbAdapter.KEY_CITY, CustomersDbAdapter.KEY_STATE, CustomersDbAdapter.KEY_ZIP }; // Specify the Corresponding layout elements where we want the columns to go int[] to = new int[] { R.id.scustomer, R.id.sname, R.id.saddress, R.id.scity, R.id.sstate, R.id.szipCode }; // Create a simple cursor adapter for the definitions and apply them to the ListView SimpleCursorAdapter customers = new SimpleCursorAdapter(this, R.layout.customerresult, cursor, from, to); mListView.setAdapter(customers); // setListViewHeightBasedOnChildren(mListView); // Define the on-click listener for the list items mListView.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // Get the cursor, positioned to the corresponding row in the result set Cursor cursor = (Cursor) mListView.getItemAtPosition(position); // Get the state's capital from this row in the database. String customer = cursor.getString(cursor.getColumnIndexOrThrow("customer")); String name = cursor.getString(cursor.getColumnIndexOrThrow("name")); String address = cursor.getString(cursor.getColumnIndexOrThrow("address")); String city = cursor.getString(cursor.getColumnIndexOrThrow("city")); String state = cursor.getString(cursor.getColumnIndexOrThrow("state")); String zipCode = cursor.getString(cursor.getColumnIndexOrThrow("zipCode")); if (address.matches("1")) { Intent intent1 = new Intent(MainActivity.this, ActivityWifiInfo.class); startActivity(intent1); overridePendingTransition(center_to_left, center_to_left2); } else if (address.matches("2")) { Intent intent2 = new Intent(MainActivity.this, ActivityWifi.class); startActivity(intent2); overridePendingTransition(center_to_left, center_to_left2); } else if (address.matches("3")) { Intent intent3 = new Intent(MainActivity.this, ActivityBth.class); startActivity(intent3); overridePendingTransition(center_to_left, center_to_left2); } else if (address.matches("4")) { Intent intent4 = new Intent(MainActivity.this, ActivityBth.class); startActivity(intent4); overridePendingTransition(center_to_left, center_to_left2); } else if (address.matches("5")) { Intent intent5 = new Intent(MainActivity.this, ActivitySota.class); startActivity(intent5); overridePendingTransition(center_to_left, center_to_left2); } else if (address.matches("6")) { Intent intent6 = new Intent(MainActivity.this, ActivitySota.class); startActivity(intent6); overridePendingTransition(center_to_left, center_to_left2); } else if (address.matches("7")) { Intent intent7 = new Intent(MainActivity.this, ActivitySota.class); startActivity(intent7); overridePendingTransition(center_to_left, center_to_left2); } else if (address.matches("8")) { Intent intent8 = new Intent(MainActivity.this, ActivityVPN.class); startActivity(intent8); overridePendingTransition(center_to_left, center_to_left2); } else if (address.matches("9")) { Intent intent9 = new Intent(MainActivity.this, ActivityVPN.class); startActivity(intent9); overridePendingTransition(center_to_left, center_to_left2); } else if (address.matches("10")) { Intent intent10 = new Intent(MainActivity.this, ActivityOperator.class); startActivity(intent10); overridePendingTransition(center_to_left, center_to_left2); } else if (address.matches("11")) { Intent intent11 = new Intent(MainActivity.this, ActivityOperator.class); startActivity(intent11); overridePendingTransition(center_to_left, center_to_left2); } else if (address.matches("12")) { Intent intent12 = new Intent(MainActivity.this, ActivityDisturb.class); startActivity(intent12); overridePendingTransition(center_to_left, center_to_left2); } else if (address.matches("13")) { Intent intent13 = new Intent(MainActivity.this, ActivityDisturb.class); startActivity(intent13); overridePendingTransition(center_to_left, center_to_left2); } else if (address.matches("14")) { Intent intent14 = new Intent(MainActivity.this, ActivityDisturb.class); startActivity(intent14); overridePendingTransition(center_to_left, center_to_left2); } else if (address.matches("15")) { Intent intent15 = new Intent(MainActivity.this, ActivityAbout.class); startActivity(intent15); overridePendingTransition(center_to_left, center_to_left2); } else if (address.matches("16")) { Intent intent16 = new Intent(MainActivity.this, ActivityInfo.class); startActivity(intent16); overridePendingTransition(center_to_left, center_to_left2); } else if (address.matches("17")) { Intent intent17 = new Intent(MainActivity.this, ActivityOsnova.class); startActivity(intent17); overridePendingTransition(center_to_left, center_to_left2); } else if (address.matches("18")) { Intent intent18 = new Intent(MainActivity.this, ActivityiCloud.class); startActivity(intent18); overridePendingTransition(center_to_left, center_to_left2); } else if (address.matches("19")) { Intent intent19 = new Intent(MainActivity.this, ActivityOsnova.class); startActivity(intent19); overridePendingTransition(center_to_left, center_to_left2); } else if (address.matches("20")) { Intent intent20 = new Intent(MainActivity.this, ActivityOsnova.class); startActivity(intent20); overridePendingTransition(center_to_left, center_to_left2); } else if (address.matches("21")) { Intent intent21 = new Intent(MainActivity.this, ActivitySetTime.class); startActivity(intent21); overridePendingTransition(center_to_left, center_to_left2); } else if (address.matches("22")) { Intent intent22 = new Intent(MainActivity.this, ActivityOsnova.class); startActivity(intent22); overridePendingTransition(center_to_left, center_to_left2); } else if (address.matches("23")) { Intent intent23 = new Intent(MainActivity.this, ActivityOsnova.class); startActivity(intent23); overridePendingTransition(center_to_left, center_to_left2); } else if (address.matches("24")) { Intent intent24 = new Intent(MainActivity.this, ActivityUsage.class); startActivity(intent24); overridePendingTransition(center_to_left, center_to_left2); } else if (address.matches("25")) { Intent intent25 = new Intent(MainActivity.this, ActivityOsnova.class); startActivity(intent25); overridePendingTransition(center_to_left, center_to_left2); } else if (address.matches("26")) { Intent intent26 = new Intent(MainActivity.this, ActivityOsnova.class); startActivity(intent26); overridePendingTransition(center_to_left, center_to_left2); } else if (address.matches("27")) { Intent intent27 = new Intent(MainActivity.this, ActivityBrightness.class); startActivity(intent27); overridePendingTransition(center_to_left, center_to_left2); } else if (address.matches("28")) { Intent intent28 = new Intent(MainActivity.this, ActivityTextSize.class); startActivity(intent28); overridePendingTransition(center_to_left, center_to_left2); } else if (address.matches("29")) { Intent intent29 = new Intent(MainActivity.this, ActivityBrightness.class); startActivity(intent29); overridePendingTransition(center_to_left, center_to_left2); } else if (address.matches("30")) { Intent intent30 = new Intent(MainActivity.this, ActivityBrightness.class); startActivity(intent30); overridePendingTransition(center_to_left, center_to_left2); } else if (address.matches("31")) { Intent intent31 = new Intent(MainActivity.this, ChooseWallpaper.class); startActivity(intent31); overridePendingTransition(center_to_left, center_to_left2); } else if (address.matches("32")) { Intent intent32 = new Intent(MainActivity.this, ActivityZvuki.class); startActivity(intent32); overridePendingTransition(center_to_left, center_to_left2); } else if (address.matches("33")) { Intent intent33 = new Intent(MainActivity.this, ActivityZvuki.class); startActivity(intent33); overridePendingTransition(center_to_left, center_to_left2); } else if (address.matches("34")) { Intent intent34 = new Intent(MainActivity.this, ActivitySetNotifications.class); startActivity(intent34); overridePendingTransition(center_to_left, center_to_left2); } else if (address.matches("35")) { Intent intent35 = new Intent(MainActivity.this, ActivitySetRingtone.class); startActivity(intent35); overridePendingTransition(center_to_left, center_to_left2); } else if (address.matches("36")) { Intent intent36 = new Intent(MainActivity.this, ActivitySetAlarms.class); startActivity(intent36); overridePendingTransition(center_to_left, center_to_left2); } else if (address.matches("37")) { Intent intent37 = new Intent(MainActivity.this, ActivityiCloud.class); startActivity(intent37); overridePendingTransition(center_to_left, center_to_left2); } else if (address.matches("38")) { Intent intent37 = new Intent(MainActivity.this, ActivityOsnova.class); startActivity(intent37); overridePendingTransition(center_to_left, center_to_left2); } else if (address.matches("39")) { Intent intent37 = new Intent(MainActivity.this, ActivityHandoff.class); startActivity(intent37); overridePendingTransition(center_to_left, center_to_left2); } else if (address.matches("40")) { Intent intent37 = new Intent(MainActivity.this, ActivityOsnova.class); startActivity(intent37); overridePendingTransition(center_to_left, center_to_left2); } else if (address.matches("41")) { Intent intent37 = new Intent(MainActivity.this, ActivityHandoff.class); startActivity(intent37); overridePendingTransition(center_to_left, center_to_left2); } else if (address.matches("42")) { Intent intent37 = new Intent(MainActivity.this, ActivityHandoff.class); startActivity(intent37); overridePendingTransition(center_to_left, center_to_left2); } searchView.setQuery("", true); } }); } }
From source file:org.openintents.shopping.ui.ShoppingActivity.java
/** * *///w w w .ja v a 2 s .co m private void fillListFilter() { // Get a cursor with all lists mCursorShoppingLists = getContentResolver().query(Lists.CONTENT_URI, mStringListFilter, null, null, mSortOrder); startManagingCursor(mCursorShoppingLists); if (mCursorShoppingLists == null) { Log.e(TAG, "missing shopping provider"); ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.list_item_shopping_list, new String[] { getString(R.string.no_shopping_provider) }); setSpinnerListAdapter(adapter); return; } if (mCursorShoppingLists.getCount() < 1) { // We have to create default shopping list: long listId = ShoppingUtils.getList(this, getText(R.string.my_shopping_list).toString()); // Check if insertion really worked. Otherwise // we may end up in infinite recursion. if (listId < 0) { // for some reason insertion did not work. return; } // The insertion should have worked, so let us call ourselves // to try filling the list again: fillListFilter(); return; } class mListContentObserver extends ContentObserver { public mListContentObserver(Handler handler) { super(handler); if (debug) { Log.i(TAG, "mListContentObserver: Constructor"); } } /* * (non-Javadoc) * * @see android.database.ContentObserver#deliverSelfNotifications() */ @Override public boolean deliverSelfNotifications() { // TODO Auto-generated method stub if (debug) { Log.i(TAG, "mListContentObserver: deliverSelfNotifications"); } return super.deliverSelfNotifications(); } /* * (non-Javadoc) * * @see android.database.ContentObserver#onChange(boolean) */ @Override public void onChange(boolean arg0) { // TODO Auto-generated method stub if (debug) { Log.i(TAG, "mListContentObserver: onChange"); } mCursorShoppingLists.requery(); super.onChange(arg0); } } mListContentObserver observer = new mListContentObserver(new Handler()); mCursorShoppingLists.registerContentObserver(observer); // Register a ContentObserver, so that a new list can be // automatically detected. // mCursor /* * ArrayList<String> list = new ArrayList<String>(); // TODO Create * summary of all lists // list.add(ALL); while * (mCursorListFilter.next()) { * list.add(mCursorListFilter.getString(mStringListFilterNAME)); } * ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, * android.R.layout.simple_spinner_item, list); * adapter.setDropDownViewResource( * android.R.layout.simple_spinner_dropdown_item); * mSpinnerListFilter.setAdapter(adapter); */ SimpleCursorAdapter adapter; if (mShoppingListsView instanceof Spinner) { adapter = new HoloThemeSimpleCursorAdapter(this, // Use a template that displays a text view R.layout.list_item_shopping_list, // Give the cursor to the list adapter mCursorShoppingLists, new String[] { Lists.NAME }, new int[] { R.id.text1 }); // adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); } else { // mShoppingListView is a ListView adapter = new SimpleCursorAdapter(this, // Use a template that displays a text view R.layout.list_item_shopping_list, // Give the cursor to the list adapter mCursorShoppingLists, new String[] { Lists.NAME }, new int[] { R.id.text1 }); } // mSpinnerListFilter.setAdapter(adapter);//Temp- redirected through // method setSpinnerListAdapter(adapter); }
From source file:com.piusvelte.sonet.core.SonetNotifications.java
private void loadNotifications() { Cursor c = this.managedQuery(Notifications.getContentUri(SonetNotifications.this), new String[] { Notifications._ID, Notifications.CLEARED, Notifications.NOTIFICATION }, Notifications.CLEARED + "!=1", null, null); SimpleCursorAdapter sca = new SimpleCursorAdapter(this, R.layout.notifications_row, c, new String[] { Notifications.CLEARED, Notifications.NOTIFICATION }, new int[] { R.id.notification, R.id.notification }); sca.setViewBinder(mViewBinder);//from w w w . ja v a2s . c o m setListAdapter(sca); }
From source file:com.shafiq.myfeedle.core.MyfeedleNotifications.java
private void loadNotifications() { Cursor c = this.managedQuery(Notifications.getContentUri(MyfeedleNotifications.this), new String[] { Notifications._ID, Notifications.CLEARED, Notifications.NOTIFICATION }, Notifications.CLEARED + "!=1", null, null); SimpleCursorAdapter sca = new SimpleCursorAdapter(this, R.layout.notifications_row, c, new String[] { Notifications.CLEARED, Notifications.NOTIFICATION }, new int[] { R.id.notification, R.id.notification }); sca.setViewBinder(mViewBinder);/*from ww w . j a va 2s . c o m*/ setListAdapter(sca); }
From source file:com.example.android.lightcontrol.MainActivity.java
private void light_configure() { LayoutInflater inflater = LayoutInflater.from(this); final View v = inflater.inflate(R.layout.light_configure, null); final AlertDialog.Builder dialog = new AlertDialog.Builder(this); helper = new DBHelper(getApplicationContext()); cursor = helper.select(TABLE_NAME_DALISLAVEADDRESS); final EditText change_light_name = (EditText) v.findViewById(R.id.editText3); Button change_name = (Button) v.findViewById(R.id.button3); final Spinner light_list = (Spinner) v.findViewById(R.id.light_list); final SimpleCursorAdapter adapter = new SimpleCursorAdapter(MainActivity.this, R.layout.message, cursor, new String[] { "_dali_name" }, new int[] { R.id.message }); light_list.setAdapter(adapter);//from www . j a v a 2 s .co m light_list.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { cursor.moveToPosition(i); } @Override public void onNothingSelected(AdapterView<?> adapterView) { } }); change_name.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { helper.update(cursor.getInt(0), TABLE_NAME_DALISLAVEADDRESS, FEILD_NAME_DALI, String.valueOf(change_light_name.getText())); helper.close(); cursor.close(); helper = new DBHelper(getApplicationContext()); cursor = helper.select(TABLE_NAME_DALISLAVEADDRESS); adapter.notifyDataSetChanged(); final Spinner light_list = (Spinner) v.findViewById(R.id.light_list); final SimpleCursorAdapter adapter = new SimpleCursorAdapter(MainActivity.this, R.layout.message, cursor, new String[] { "_dali_name" }, new int[] { R.id.message }); light_list.setAdapter(adapter); } }); dialog.setCancelable(false); dialog.setTitle(R.string.about_title); dialog.setView(v); dialog.setPositiveButton(R.string.ok_label_1, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialoginterface, int i) { updatespinner(); helper.close(); cursor.close(); } }); dialog.show(); }