本文整理匯總了Java中android.support.v4.widget.SimpleCursorAdapter.setDropDownViewResource方法的典型用法代碼示例。如果您正苦於以下問題:Java SimpleCursorAdapter.setDropDownViewResource方法的具體用法?Java SimpleCursorAdapter.setDropDownViewResource怎麽用?Java SimpleCursorAdapter.setDropDownViewResource使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.support.v4.widget.SimpleCursorAdapter
的用法示例。
在下文中一共展示了SimpleCursorAdapter.setDropDownViewResource方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setUpCategoriesSpinner
import android.support.v4.widget.SimpleCursorAdapter; //導入方法依賴的package包/類
private void setUpCategoriesSpinner() {
String[] columns = new String[] { Categories.CATEGORY };
getSupportLoaderManager().restartLoader(1, null, this);
categoriesAdapter = new SimpleCursorAdapter(this, R.layout.spinner_category, null, columns,
new int[] { android.R.id.text1 }, 0);
ArrayAdapter<String> allRecipesAdapter = new ArrayAdapter<String>(this,
R.layout.spinner_category, android.R.id.text1, new String[] {
getString(R.string.all_recipes), getString(R.string.favorites) });
allRecipesAdapter.setDropDownViewResource(R.layout.drop_down_item_category);
categoriesAdapter.setDropDownViewResource(R.layout.drop_down_item_category);
MergeSpinnerAdapter mergeAdapter = new MergeSpinnerAdapter();
mergeAdapter.addAdapter(allRecipesAdapter);
mergeAdapter.addAdapter(categoriesAdapter);
getSupportActionBar().setListNavigationCallbacks(mergeAdapter, this);
}
示例2: populateContactsSpinner
import android.support.v4.widget.SimpleCursorAdapter; //導入方法依賴的package包/類
private void populateContactsSpinner(View root) {
// Query for list of contacts
String accountName = getString(R.string.account_name);
String accountType = getString(R.string.account_type);
Cursor cursor = ContactsUtils.queryRawContacts(getActivity(), accountName, accountType);
// Create adapter to display contacts in spinner
String[] adapterCols = new String[] { ContactsContract.RawContacts.DISPLAY_NAME_PRIMARY };
int[] adapterRowViews = new int[] { android.R.id.text1 };
mContactAdapter = new SimpleCursorAdapter(getActivity(), android.R.layout.simple_spinner_item, cursor, adapterCols, adapterRowViews, 0);
// Specify the layout to use when the list of choices appears
mContactAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
// Apply the adapter to the spinner
mContactSpinner.setAdapter(mContactAdapter);
// If a contact id is available set the spinner selection:
String gwid = gift.getGiftwiseId();
if (gwid == null) {
mContactSpinner.setSelection(0);
} else {
selectSpinnerItemByContactId(gwid);
}
}
示例3: onCreateView
import android.support.v4.widget.SimpleCursorAdapter; //導入方法依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup root, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_edit_spp_item, root);
mTxtSpeciesItemLabel = (TextView) view.findViewById(R.id.lbl_spp_item);
mTxtSppDupLabel = (TextView) view.findViewById(R.id.lbl_spp_dups);
mTxtHeightLabel = (TextView) view.findViewById(R.id.lbl_spp_height);
mEditSpeciesHeight = (EditText) view.findViewById(R.id.txt_spp_height);
mTxtCoverLabel = (TextView) view.findViewById(R.id.lbl_spp_cover);
mEditSpeciesCover = (EditText) view.findViewById(R.id.txt_spp_cover);
mCkSpeciesIsPresent = (CheckBox) view.findViewById(R.id.ck_spp_present);
mCkDontVerifyPresence = (CheckBox) view.findViewById(R.id.ck_spp_present_do_not_ask);
mTxtSppCFLabel = (TextView) view.findViewById(R.id.lbl_spp_confidence);
mSpinnerSpeciesConfidence = (Spinner) view.findViewById(R.id.spinner_spp_confidence);
mSpinnerSpeciesConfidence.setTag(Tags.SPINNER_FIRST_USE); // flag to catch and ignore erroneous first firing
mSpinnerSpeciesConfidence.setEnabled(false); // will enable when data ready
mCFSpinnerAdapter = new SimpleCursorAdapter(getActivity(),
android.R.layout.simple_spinner_item, null,
new String[] {"IdLevelDescr"},
new int[] {android.R.id.text1}, 0);
mCFSpinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
mSpinnerSpeciesConfidence.setAdapter(mCFSpinnerAdapter);
mSpinnerSpeciesConfidence.setOnItemSelectedListener(this);
mEditSpeciesHeight.setOnFocusChangeListener(this);
mEditSpeciesCover.setOnFocusChangeListener(this);
mCkSpeciesIsPresent.setOnFocusChangeListener(this);
mCkDontVerifyPresence.setOnFocusChangeListener(this);
// enable long-press
registerForContextMenu(mSpinnerSpeciesConfidence);
registerForContextMenu(mEditSpeciesHeight);
registerForContextMenu(mEditSpeciesCover);
registerForContextMenu(mCkSpeciesIsPresent);
registerForContextMenu(mCkDontVerifyPresence);
getDialog().setTitle(R.string.edit_spp_item_title_add); // usually adding, will change to 'edit' if not
return view;
}
示例4: fillFieldValues
import android.support.v4.widget.SimpleCursorAdapter; //導入方法依賴的package包/類
private void fillFieldValues() {
String[] column = new String[]{Constants.FIELD_ID, mSelectedField};
String[] from = new String[]{mSelectedField};
int[] to = new int[]{android.R.id.text1};
MapContentProviderHelper map = (MapContentProviderHelper) MapBase.getInstance();
SQLiteDatabase db = map.getDatabase(true);
mData = db.query(true, mLayer.getPath().getName(), column, null, null, column[1], null, null, null);
mValueAdapter = new SimpleCursorAdapter(getContext(), android.R.layout.simple_spinner_item, mData, from, to, 0);
mValueAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
mStyleRule.setKey(mSelectedField);
}
示例5: onCreateView
import android.support.v4.widget.SimpleCursorAdapter; //導入方法依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// if the activity was re-created (e.g. from a screen rotate)
// restore the previous screen, remembered by onSaveInstanceState()
// This is mostly needed in fixed-pane layouts
if (savedInstanceState != null) {
mCurrentSubplot = savedInstanceState.getInt(ARG_SUBPLOT);
}
// inflate the layout for this fragment
View rootView = inflater.inflate(R.layout.fragment_new_visit, container, false);
// Button s = (Button) rootView.findViewById(R.id.sign_in_button);
// s.setOnClickListener(this);
// set click listener for the "Start" button in the view
Button b = (Button) rootView.findViewById(R.id.new_visit_go_button);
b.setOnClickListener(this);
// if more, loop through all the child items of the ViewGroup rootView and
// set the onclicklistener for all the Button instances found
// Create an empty adapter we will use to display the list of Projects
mProjSpinner = (Spinner) rootView.findViewById(R.id.sel_project_spinner);
mProjSpinner.setEnabled(false); // will enable when data ready
mProjAdapter = new SimpleCursorAdapter(getActivity(),
android.R.layout.simple_spinner_item, null,
new String[] {"ProjCode"},
new int[] {android.R.id.text1}, 0);
mProjAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
mProjSpinner.setAdapter(mProjAdapter);
mProjSpinner.setOnItemSelectedListener(this);
// Prepare the loader. Either re-connect with an existing one or start a new one
getLoaderManager().initLoader(VNContract.Loaders.PROJECTS, null, this);
// If there in no Loader yet, this will call
// Loader<Cursor> onCreateLoader and pass it a first parameter of Loaders.PROJECTS
mPlotTypeSpinner = (Spinner) rootView.findViewById(R.id.sel_plot_type_spinner);
mPlotTypeSpinner.setEnabled(false); // will enable when data ready
mPlotTypeAdapter = new SimpleCursorAdapter(getActivity(),
android.R.layout.simple_spinner_item, null,
new String[] {"PlotTypeDescr"},
new int[] {android.R.id.text1}, 0);
mPlotTypeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
mPlotTypeSpinner.setAdapter(mPlotTypeAdapter);
mPlotTypeSpinner.setOnItemSelectedListener(this);
getLoaderManager().initLoader(VNContract.Loaders.PLOTTYPES, null, this);
mVisitListAdapter = new SimpleCursorAdapter(getActivity(),
android.R.layout.simple_list_item_2, null,
new String[] {"VisitName", "VisDescr"},
new int[] {android.R.id.text1, android.R.id.text2}, 0);
setListAdapter(mVisitListAdapter);
getLoaderManager().initLoader(VNContract.Loaders.PREV_VISITS, null, this);
return rootView;
}
示例6: onCreateView
import android.support.v4.widget.SimpleCursorAdapter; //導入方法依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// inflate the layout for this fragment
View rootView = inflater.inflate(R.layout.fragment_manage_phs, container, false);
mPhNamerSpinner = (Spinner) rootView.findViewById(R.id.sel_namer_spinner);
mPhNamerSpinner.setTag(VNContract.Tags.SPINNER_FIRST_USE); // flag to catch and ignore erroneous first firing
mPhNamerSpinner.setEnabled(false); // will enable when data ready
mPhNamerAdapter = new SimpleCursorAdapter(getActivity(),
android.R.layout.simple_spinner_item, null,
new String[] {"NamerName"},
new int[] {android.R.id.text1}, 0);
mPhNamerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
mPhNamerSpinner.setAdapter(mPhNamerAdapter);
mPhNamerSpinner.setOnItemSelectedListener(this);
registerForContextMenu(mPhNamerSpinner); // enable long-press
// Prepare the loader. Either re-connect with an existing one or start a new one
getLoaderManager().initLoader(Loaders.PHS_NAMERS, null, this);
/* may not need cover
// also need click, if no names & therefore selection cannot be changed
// mPhNamerSpinner.setOnFocusChangeListener(this); // does not work
// use a TextView on top of the spinner, named "lbl_spp_namer_spinner_cover"
mLblNewNamerSpinnerCover = (TextView) rootView.findViewById(R.id.lbl_spp_namer_spinner_cover);
mLblNewNamerSpinnerCover.setOnClickListener(this);
registerForContextMenu(mLblNewNamerSpinnerCover); // enable long-press
// in layout, TextView is in front of Spinner and takes precedence
// for testing context menu, bring spinner to front so it receives clicks
// mPhNamerSpinner.bringToFront();
*/
mPhSortSpinner = (Spinner) rootView.findViewById(R.id.ph_sort_spinner);
mPhSortSpinner.setTag(VNContract.Tags.SPINNER_FIRST_USE); // flag to catch and ignore erroneous first firing
// Create an ArrayAdapter using the string array and a default spinner layout
ArrayAdapter<CharSequence> phSortAdapter = ArrayAdapter.createFromResource(getActivity(),
R.array.phs_sort_options_array, android.R.layout.simple_spinner_item);
// Specify the layout to use when the list of choices appears
phSortAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
// Apply the adapter to the spinner
mPhSortSpinner.setAdapter(phSortAdapter);
mPhSortSpinner.setOnItemSelectedListener(this);
mViewSearchChars = (EditText) rootView.findViewById(R.id.txt_search_phs);
mViewSearchChars.addTextChangedListener(sppCodeTextWatcher);
// registerForContextMenu(mViewSearchChars); // enable long-press
mViewCkPhsNotIdd = (CheckBox) rootView.findViewById(R.id.ck_show_phs_not_idd);
mViewCkPhsNotIdd.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
refreshPhsList();
}
});
mViewForEmptyList = (TextView) rootView.findViewById(android.R.id.empty);
// use query to return 'MatchTxt', concatenated from code and description; more reading room
// use same internal layout for items as in species search fragment
mPhResultsAdapter = new SelSppItemAdapter(getActivity(),
R.layout.list_spp_search_item, null, 0);
setListAdapter(mPhResultsAdapter);
getLoaderManager().initLoader(Loaders.PHS_MATCHES, null, this);
return rootView;
}
示例7: setupAccountSpinner
import android.support.v4.widget.SimpleCursorAdapter; //導入方法依賴的package包/類
private void setupAccountSpinner ()
{
final Uri uri = Imps.Provider.CONTENT_URI_WITH_ACCOUNT;
mCursorProviders = 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_item, mCursorProviders,
new String[] {
Imps.Provider.ACTIVE_ACCOUNT_USERNAME
},
new int[] { android.R.id.text1 });
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
// TODO Something is causing the managedQuery() to return null, use null guard for now
if (mCursorProviders != null && mCursorProviders.getCount() > 0)
{
mCursorProviders.moveToFirst();
mProviderId = mCursorProviders.getLong(PROVIDER_ID_COLUMN);
mAccountId = mCursorProviders.getLong(ACTIVE_ACCOUNT_ID_COLUMN);
}
/**
mListSpinner.setAdapter(adapter);
mListSpinner.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
if (mCursorProviders == null)
return;
mCursorProviders.moveToPosition(arg2);
mProviderId = mCursorProviders.getLong(PROVIDER_ID_COLUMN);
mAccountId = mCursorProviders.getLong(ACTIVE_ACCOUNT_ID_COLUMN);
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
});
*/
}