本文整理汇总了Java中android.widget.Spinner.getAdapter方法的典型用法代码示例。如果您正苦于以下问题:Java Spinner.getAdapter方法的具体用法?Java Spinner.getAdapter怎么用?Java Spinner.getAdapter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.Spinner
的用法示例。
在下文中一共展示了Spinner.getAdapter方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: selectSpinnerItemByValue
import android.widget.Spinner; //导入方法依赖的package包/类
/**
*
* @param spnr
* @param value
*
* solution based on an answer from stack overflow
* resource: https://stackoverflow.com/questions/11072576/set-selected-item-of-spinner-programmatically
*
*/
public static void selectSpinnerItemByValue(Spinner spnr, String value) {
ArrayAdapter<String> adapter = (ArrayAdapter<String>) spnr.getAdapter();
String currentItem;
for (int i = 0; i < adapter.getCount(); i++) {
currentItem = adapter.getItem(i);
if(currentItem.equals(value)) {
spnr.setSelection(i);
return;
}
}
}
示例2: setSpinnerPosition
import android.widget.Spinner; //导入方法依赖的package包/类
private static void setSpinnerPosition(final Spinner spinner, final Object itemToSelect) {
final SpinnerAdapter adapter = spinner.getAdapter();
final int count = adapter.getCount();
for (int i = 0; i < count; i++) {
final Object item = spinner.getItemAtPosition(i);
if (item.equals(itemToSelect)) {
spinner.setSelection(i);
return;
}
}
}
示例3: setSpinnerSelectedID
import android.widget.Spinner; //导入方法依赖的package包/类
@SuppressWarnings("ConstantConditions")
public void setSpinnerSelectedID(Spinner sp, String text) {
ArrayAdapter sca = (ArrayAdapter) sp.getAdapter();
if (sca == null) {
return;
}
for (int i = 0; i < sca.getCount(); i++) {
if (sca.getItem(i) != null && sca.getItem(i).toString().equals(text)) {
sp.setSelection(i);
return;
}
}
}
示例4: updateSelectedPreset
import android.widget.Spinner; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public void updateSelectedPreset(Spinner spinner, TGBendPreset selection) {
ArrayAdapter<TGSelectableItem> adapter = (ArrayAdapter<TGSelectableItem>) spinner.getAdapter();
spinner.setSelection(adapter.getPosition(new TGSelectableItem(selection, null)), false);
}
示例5: updateSpinnerSelection
import android.widget.Spinner; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public void updateSpinnerSelection(Spinner spinner, int selection) {
ArrayAdapter<TGSelectableItem> adapter = (ArrayAdapter<TGSelectableItem>) spinner.getAdapter();
spinner.setSelection(adapter.getPosition(new TGSelectableItem(Integer.valueOf(selection), null)), false);
}
示例6: updateSelectedPreset
import android.widget.Spinner; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public void updateSelectedPreset(Spinner spinner, TGTremoloBarPreset selection) {
ArrayAdapter<TGSelectableItem> adapter = (ArrayAdapter<TGSelectableItem>) spinner.getAdapter();
spinner.setSelection(adapter.getPosition(new TGSelectableItem(selection, null)), false);
}
示例7: fillInData
import android.widget.Spinner; //导入方法依赖的package包/类
private void fillInData(SharedPreferences prefs) {
//Edittext's connected to the fields in the student profile.
EditText fullName = (EditText) findViewById(R.id.studentNameSettings);
EditText email = (EditText) findViewById(R.id.studentEmailSettings);
EditText major = (EditText) findViewById(R.id.studentMajorSettings);
EditText city = (EditText) findViewById(R.id.studentCitySettings);
EditText gradYear = (EditText) findViewById(R.id.studentGradYearSettings);
EditText un = (EditText) findViewById(R.id.studentUsernameSettings);
EditText pw = (EditText) findViewById(R.id.studentPasswordSettings);
//Spinners for displaying states, and terms of graduation.
Spinner stateSpinner = (Spinner) findViewById(R.id.stateSpinnerSettings);
Spinner gradTermSpinner = (Spinner) findViewById(R.id.FallSpringSpinnerSettings);
ArrayAdapter stateAdapter = (ArrayAdapter) stateSpinner.getAdapter();
ArrayAdapter gradTermAdapter = (ArrayAdapter) gradTermSpinner.getAdapter();
int statePos = stateAdapter.getPosition(prefs.getString("state","") );
int gradPos = gradTermAdapter.getPosition(prefs.getString("gradTerm","") );
//Getting data from the shared preferences to populate the student profile fields.
fullName.setText(prefs.getString("fullName", ""));
email.setText(prefs.getString("email",""));
major.setText(prefs.getString("major",""));
city.setText(prefs.getString("city",""));
gradYear.setText(prefs.getString("gradYear",""));
un.setText(prefs.getString("username",""));
pw.setText(prefs.getString("password",""));
stateSpinner.setSelection(statePos);
gradTermSpinner.setSelection(gradPos);
//Create new profile pic object.
pic = new ProfilePic(null);
ImageView profilePic = (ImageView) findViewById(R.id.thumbnailSettings);
String imgString = prefs.getString("profilePic", "");
//If the image string is blank, set the profile pic in the layout to the default
//camera drawable image.
if(imgString == "")
profilePic.setImageDrawable(getResources().getDrawable(R.drawable.ic_menu_camera));
//Otherwise, decode the image string, and use that bitmap for the profile pic.
else {
pic.setBitmap(pic.getDecodedBitmap(imgString));
profilePic.setImageBitmap(pic.getResizedBitmap());
}
}
示例8: prepareRestoreWalletDialog
import android.widget.Spinner; //导入方法依赖的package包/类
private void prepareRestoreWalletDialog(final Dialog dialog) {
final AlertDialog alertDialog = (AlertDialog) dialog;
final String path;
final String backupPath = Constants.Files.EXTERNAL_WALLET_BACKUP_DIR.getAbsolutePath();
final String storagePath = Constants.Files.EXTERNAL_STORAGE_DIR.getAbsolutePath();
if (backupPath.startsWith(storagePath))
path = backupPath.substring(storagePath.length());
else
path = backupPath;
final List<File> files = new LinkedList<File>();
// external storage
final File[] externalFiles = Constants.Files.EXTERNAL_WALLET_BACKUP_DIR.listFiles();
if (externalFiles != null)
for (final File file : externalFiles)
if (Crypto.OPENSSL_FILE_FILTER.accept(file))
files.add(file);
// internal storage
for (final String filename : fileList())
if (filename.startsWith(Constants.Files.WALLET_KEY_BACKUP_PROTOBUF + '.'))
files.add(new File(getFilesDir(), filename));
// sort
Collections.sort(files, new Comparator<File>() {
@Override
public int compare(final File lhs, final File rhs) {
return lhs.getName().compareToIgnoreCase(rhs.getName());
}
});
final TextView messageView = (TextView) alertDialog.findViewById(R.id.restore_wallet_dialog_message);
messageView.setText(getString(
!files.isEmpty() ? R.string.import_keys_dialog_message : R.string.restore_wallet_dialog_message_empty,
path));
final Spinner fileView = (Spinner) alertDialog.findViewById(R.id.import_keys_from_storage_file);
fileView.setVisibility(!files.isEmpty() ? View.VISIBLE : View.GONE);
final FileAdapter adapter = (FileAdapter) fileView.getAdapter();
adapter.setFiles(files);
final EditText passwordView = (EditText) alertDialog.findViewById(R.id.import_keys_from_storage_password);
passwordView.setVisibility(!files.isEmpty() ? View.VISIBLE : View.GONE);
passwordView.setText(null);
final CheckBox showView = (CheckBox) alertDialog.findViewById(R.id.import_keys_from_storage_show);
showView.setVisibility(!files.isEmpty() ? View.VISIBLE : View.GONE);
showView.setOnCheckedChangeListener(new ShowPasswordCheckListener(passwordView));
final View replaceWarningView = alertDialog
.findViewById(R.id.restore_wallet_from_storage_dialog_replace_warning);
final boolean hasCoins = wallet.getBalance(BalanceType.ESTIMATED).signum() > 0;
replaceWarningView.setVisibility(hasCoins ? View.VISIBLE : View.GONE);
final ImportDialogButtonEnablerListener dialogButtonEnabler = new ImportDialogButtonEnablerListener(
passwordView, alertDialog) {
@Override
protected boolean hasFile() {
return fileView.getSelectedItem() != null;
}
@Override
protected boolean needsPassword() {
final File selectedFile = (File) fileView.getSelectedItem();
return selectedFile != null ? Crypto.OPENSSL_FILE_FILTER.accept(selectedFile) : false;
}
};
passwordView.addTextChangedListener(dialogButtonEnabler);
fileView.setOnItemSelectedListener(dialogButtonEnabler);
}