本文整理汇总了Java中android.widget.Spinner.getSelectedItem方法的典型用法代码示例。如果您正苦于以下问题:Java Spinner.getSelectedItem方法的具体用法?Java Spinner.getSelectedItem怎么用?Java Spinner.getSelectedItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.Spinner
的用法示例。
在下文中一共展示了Spinner.getSelectedItem方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onDataChange
import android.widget.Spinner; //导入方法依赖的package包/类
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
EditText username = (EditText)findViewById(R.id.usernameText);
name = username.getText().toString();
EditText password = (EditText)findViewById(R.id.passwordText);
pass = password.getText().toString();
Spinner grabAccountType = findViewById(R.id.accountTypeSpinner);
String accountType = (String) grabAccountType.getSelectedItem();
if (!(dataSnapshot.child(email).hasChild(name))) {
if (accountType.equals("Child")) {
newUser = new User(name, pass, MenuActivity.getManager().nextSerialNumber(), resID);
manager.setCurrentUserId(newUser.getUserId());
manager.addRegUser(newUser);
fbRef.child(email).child("ChoreManager").setValue(manager);
} else {
newAdminUser = new AdminUser(name, pass, MenuActivity.getManager().nextSerialNumber(), resID);
manager.setCurrentUserId(newAdminUser.getUserId());
manager.addAdminUser(newAdminUser);
fbRef.child(email).child("ChoreManager").setValue(manager);
}
}
finish();
}
示例2: getTimeSpanFromDialog
import android.widget.Spinner; //导入方法依赖的package包/类
public static TimeSpan getTimeSpanFromDialog(Context context, View dialog)
{
EditText timeSpanEditText = (EditText) dialog.findViewById(R.id.timeSpanEditText);
Spinner timeSpanSpinner = (Spinner) dialog.findViewById(R.id.timeSpanSpinner);
if (timeSpanEditText == null || timeSpanSpinner == null)
{
return new TimeSpan(-1);
}
String timeSpanType = (String) timeSpanSpinner.getSelectedItem();
Editable text = timeSpanEditText.getText();
String timeSpanAmountString = null;
if (text != null)
{
timeSpanAmountString = text.toString();
}
int timeSpanAmount = 0;
if (timeSpanAmountString != null && !"".equals(timeSpanAmountString))
{
timeSpanAmount = Integer.parseInt(timeSpanAmountString);
}
return calculateTimeSpan(context, timeSpanType, timeSpanAmount);
}
示例3: isValid
import android.widget.Spinner; //导入方法依赖的package包/类
private boolean isValid() {
boolean ret = true;
int max = scrollView.getChildCount();
for (int i = 0; i < max; i++) {
Spinner spiner = (Spinner) scrollView.getChildAt(i);
if (spiner.getSelectedItem() == null) {
ret = false;
}
}
return ret;
}
示例4: saveExitOnClick
import android.widget.Spinner; //导入方法依赖的package包/类
public void saveExitOnClick(View view){
Intent intent = new Intent(this, ChoreListActivity.class);
// Linking objects to XML
EditText grabChoreName = (EditText) findViewById(R.id.choreNameInput); //Chore Name
Spinner grabAssignedTo = findViewById(R.id.assignToSpiner); //Who the Chore is assigned to
Spinner grabChoreType = findViewById(R.id.choreTypeSpinner); // THe type of chore
Spinner grabPoints = findViewById(R.id.totalPointsSpinner); // The points the chore is worth
Spinner grabResources = findViewById(R.id.requiredMaterialsSpinner); //The list of materials
EditText grabDesc = (EditText) findViewById(R.id.descTextView2); //Description of Chore
EditText grabNote = (EditText) findViewById(R.id.notesTextView); //Note of Chore
//Simple variables from newChoreActivity
//All information needed to create a chore.
String choreName = grabChoreName.getText().toString();
String choreAssignedTo = (String) grabAssignedTo.getSelectedItem();
String choreType = (String) grabChoreType.getSelectedItem();
String choreDesc = grabDesc.getText().toString();
String choreNote = grabNote.getText().toString();
int choreTotalPoints = Integer.parseInt((String)grabPoints.getSelectedItem());
//FIND ALL MATERIALS THAT WERE SELECTED
List<String> resources= new ArrayList<String>();
for(int i = 0; i < allMaterials.size(); i++){
StateVO currentItem = (StateVO)grabResources.getItemAtPosition(i);
if ( currentItem.isSelected() ){
resources.add(currentItem.getTitle());
}
}
//Gets the user the chore is assigned to and the current user.
User assignedUser = MenuActivity.getManager().getUserFromName(choreAssignedTo);
//Administrator user
AdminUser currentUser = MenuActivity.getManager().getAdminUserFromId(MenuActivity.getManager().getCurrentUserId());
Chore newChore; //Chore being made.
if (assignedUser == null || assignedUser.getUsername().equals("None")){ //UNASSIGNED CHORE
newChore = currentUser.createUnAssignedChore(choreName, choreDesc, choreNote, choreTotalPoints, choreType,
dateTime.getTime(),resources , MenuActivity.getManager().nextSerialNumber() );
MenuActivity.getManager().addUnassignedChores(newChore);
}
else{
newChore = currentUser.createChore(choreName, choreDesc, choreNote, choreTotalPoints, choreType, //If theres a User to assign
dateTime.getTime(), resources, MenuActivity.getManager().nextSerialNumber(), assignedUser);
}
//Writing to database
MenuActivity.getFbRef().child(MenuActivity.getEmail()).child("ChoreManager").setValue(MenuActivity.getManager());
startActivity(intent);
finish();
}
示例5: saveExitOnClick
import android.widget.Spinner; //导入方法依赖的package包/类
public void saveExitOnClick(View view){
//Clear Stack and Make MenuScreen and Go back to Chore List
Intent mainIntent = new Intent(EditChoreActivity.this, MenuActivity.class);
// Linking objects to XML
EditText grabChoreName = (EditText) findViewById(R.id.choreNameInput); //Chore Name
Spinner grabAssignedTo = findViewById(R.id.assignToSpiner); //Who the Chore is assigned to
Spinner grabChoreType = findViewById(R.id.choreTypeSpinner); // THe type of chore
Spinner grabPoints = findViewById(R.id.totalPointsSpinner); // The points the chore is worth
Spinner grabResources = findViewById(R.id.requiredMaterialsSpinner); //The list of materials
EditText grabDesc = (EditText) findViewById(R.id.descTextView2); //Description of Chore
EditText grabNote = (EditText) findViewById(R.id.notesTextView); //Note of Chore
//Simple variables from newChoreActivity
String choreName = grabChoreName.getText().toString();
String choreAssignedTo = (String) grabAssignedTo.getSelectedItem();
String choreType = (String) grabChoreType.getSelectedItem();
String choreDesc = grabDesc.getText().toString();
String choreNote = grabNote.getText().toString();
int choreTotalPoints = Integer.parseInt((String)grabPoints.getSelectedItem());
//FIND ALL MATERIALS THAT WERE SELECTED
List<String> resources= new ArrayList<String>();
for(int i = 0; i < allMaterials.size(); i++){
StateVO currentItem = (StateVO)grabResources.getItemAtPosition(i);
if ( currentItem.isSelected() ){
resources.add(currentItem.getTitle());
}
}
Date choreDeadline = dateTime.getTime(); //Deadline
//GETTING OLD CHORE TO CHECK IF TIME IS SAME AND TO REMOVE OLDCHORE LATER.
Intent choreIntent = getIntent();
Chore oldChore = (Chore) choreIntent.getSerializableExtra("ChoreInfo2");
//Checking if User did not change chore time.
if(formatDateTime.format(oldChore.getDeadline()).equals(actualDeadlineTextView.getText().toString())){
choreDeadline = oldChore.getDeadline();
}
//Gets the user the chore is assigne to and the current user.
User assignedUser = MenuActivity.getManager().getUserFromName(choreAssignedTo);
//Administrator user
AdminUser currentUser = MenuActivity.getManager().getAdminUserFromId(MenuActivity.getManager().getCurrentUserId());
Chore newChore; //Chore thats being created
if (assignedUser == null || assignedUser.getUsername().equals("None")){ //UNASSIGNED CHORE
newChore = currentUser.createUnAssignedChore(choreName, choreDesc, choreNote, choreTotalPoints, choreType,
choreDeadline,resources , MenuActivity.getManager().nextSerialNumber() );
MenuActivity.getManager().addUnassignedChores(newChore);
}
else{
newChore = currentUser.createChore(choreName, choreDesc, choreNote, choreTotalPoints, choreType, //If theres a User to assign
choreDeadline, resources, MenuActivity.getManager().nextSerialNumber(), assignedUser);
}
MenuActivity.getManager().removeChore(oldChore.getChoreId()); //Delete old chore
MenuActivity.getFbRef().child(MenuActivity.getEmail()).child("ChoreManager").setValue(MenuActivity.getManager()); //Write to Database
mainIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(mainIntent);
Intent intent = new Intent(EditChoreActivity.this, ChoreListActivity.class);
startActivity(intent);
finish();
}
示例6: onBookLinkSetRequest
import android.widget.Spinner; //导入方法依赖的package包/类
@Override
public void onBookLinkSetRequest(final long bookId) {
final Book book = BooksClient.get(this, bookId);
if (book == null) {
return;
}
Map<String, Repo> repos = ReposClient.getAll(this);
if (repos.size() == 0) {
showSnackbarWithReposLink(getString(R.string.no_repos));
return;
}
LinkedHashMap<String, Integer> items = new LinkedHashMap<>();
int itemIndex = 0;
/* Add "no link" item. */
items.put(getString(R.string.no_link), itemIndex++);
/* Add repositories. */
for (String repoUri : repos.keySet()) {
items.put(repoUri, itemIndex++);
}
View view = getLayoutInflater().inflate(R.layout.dialog_spinner, null, false);
final Spinner spinner = (Spinner) view.findViewById(R.id.dialog_spinner);
ArrayAdapter<String> adapter = new ArrayAdapter<>(spinner.getContext(), R.layout.spinner_item, new ArrayList<>(items.keySet()));
adapter.setDropDownViewResource(R.layout.dropdown_item);
spinner.setAdapter(adapter);
/* Set spinner to current book's link. */
if (book.getLink() != null) {
Integer pos = items.get(book.getLink().getRepoUri().toString());
if (pos != null) {
spinner.setSelection(pos);
}
}
DialogInterface.OnClickListener dialogClickListener = (dialog, which) -> {
switch (which) {
case DialogInterface.BUTTON_POSITIVE:
Shelf shelf = new Shelf(MainActivity.this);
String repoUrl = (String) spinner.getSelectedItem();
if (getString(R.string.no_link).equals(repoUrl)) {
shelf.setLink(book, null);
} else {
shelf.setLink(book, repoUrl);
}
break;
case DialogInterface.BUTTON_NEGATIVE:
break;
}
};
new AlertDialog.Builder(this)
.setTitle("Link " + MiscUtils.quotedString(book.getName()) + " to repository")
.setView(view)
.setPositiveButton(R.string.set, dialogClickListener)
.setNegativeButton(R.string.cancel, dialogClickListener)
.show();
}
示例7: captureSelectedValue
import android.widget.Spinner; //导入方法依赖的package包/类
@InverseBindingAdapter(attribute = "bind:selectedValue", event = "bind:selectedValueAttrChanged")
public static String captureSelectedValue(Spinner pSpinner) {
return (String) pSpinner.getSelectedItem();
}
示例8: FromView
import android.widget.Spinner; //导入方法依赖的package包/类
public void FromView() {
if (getView() == null || m_le == null)
return;
// Integer fields
m_le.cApproaches = IntFromField(R.id.txtApproaches);
m_le.cFullStopLandings = IntFromField(R.id.txtDayLandings);
m_le.cLandings = IntFromField(R.id.txtLandings);
m_le.cNightLandings = IntFromField(R.id.txtFSNightLandings);
// Double fields
m_le.decCFI = DoubleFromField(R.id.txtCFI);
m_le.decDual = DoubleFromField(R.id.txtDual);
m_le.decGrndSim = DoubleFromField(R.id.txtGround);
m_le.decIMC = DoubleFromField(R.id.txtIMC);
m_le.decNight = DoubleFromField(R.id.txtNight);
m_le.decPIC = DoubleFromField(R.id.txtPIC);
m_le.decSIC = DoubleFromField(R.id.txtSIC);
m_le.decSimulatedIFR = DoubleFromField(R.id.txtSimIMC);
m_le.decTotal = DoubleFromField(R.id.txtTotal);
m_le.decXC = DoubleFromField(R.id.txtXC);
m_le.hobbsStart = DoubleFromField(R.id.txtHobbsStart);
m_le.hobbsEnd = DoubleFromField(R.id.txtHobbsEnd);
// Date - no-op because it should be in sync
// Flight/Engine times - ditto
// checkboxes
m_le.fHold = CheckState(R.id.ckHold);
m_le.fPublic = CheckState(R.id.ckMyFlightbook);
// And strings
m_le.szComments = StringFromField(R.id.txtComments);
m_le.szRoute = StringFromField(R.id.txtRoute);
// Aircraft spinner
Aircraft[] rgSelectibleAircraft = SelectibleAircraft();
if (rgSelectibleAircraft != null && rgSelectibleAircraft.length > 0) {
Spinner sp = (Spinner) findViewById(R.id.spnAircraft);
m_le.idAircraft = ((Aircraft) sp.getSelectedItem()).AircraftID;
}
// Posting options
m_po.m_fPostFacebook = CheckState(R.id.ckFacebook);
m_po.m_fTweet = CheckState(R.id.ckTwitter);
}
示例9: AutoTotals
import android.widget.Spinner; //导入方法依赖的package包/类
private void AutoTotals() {
double dtHobbs = 0;
double dtTotal = 0;
double dtFlight = 0;
double dtEngine = 0;
FromView();
// compute the flight time, in hours, if known
if (m_le.isKnownFlightTime())
dtFlight = (m_le.dtFlightEnd.getTime() - m_le.dtFlightStart.getTime() - totalTimePaused()) / MFBConstants.MS_PER_HOUR;
if (m_le.isKnownEngineTime())
dtEngine = (m_le.dtEngineEnd.getTime() - m_le.dtEngineStart.getTime() - totalTimePaused()) / MFBConstants.MS_PER_HOUR;
// NOTE: we do NOT subtract totalTimePaused here because hobbs should already have subtracted pause time,
// whether from being entered by user (hobbs on airplane pauses on ground or with engine stopped)
// or from this being called by autohobbs (which has already subtracted it)
if (m_le.hobbsStart > 0 && m_le.hobbsEnd > m_le.hobbsStart)
dtHobbs = m_le.hobbsEnd - m_le.hobbsStart; // hobbs is already in hours
// do autotime
switch (MFBLocation.fPrefAutoFillTime) {
case EngineTime:
dtTotal = dtEngine;
break;
case FlightTime:
dtTotal = dtFlight;
break;
case HobbsTime:
dtTotal = dtHobbs;
break;
default:
break;
}
if (dtTotal > 0) {
Boolean fIsReal = true;
Spinner sp = (Spinner) findViewById(R.id.spnAircraft);
if (MFBLocation.fPrefRoundNearestTenth)
dtTotal = Math.round(dtTotal * 10.0) / 10.0;
if (m_le.idAircraft > 0 && sp.getSelectedItem() != null)
fIsReal = (((Aircraft) sp.getSelectedItem()).InstanceTypeID == 1);
// update totals and XC if this is a real aircraft, else ground sim
if (fIsReal) {
m_le.decTotal = dtTotal;
m_le.decXC = (Airport.MaxDistanceForRoute(m_le.szRoute) > MFBConstants.NM_FOR_CROSS_COUNTRY) ? dtTotal : 0.0;
} else
m_le.decGrndSim = dtTotal;
ToView();
}
}
示例10: findSelectedData
import android.widget.Spinner; //导入方法依赖的package包/类
public int findSelectedData(View view) {
Spinner spinner = (Spinner) view.findViewById(R.id.harmonic_dlg_data_value);
TGSelectableItem selectableItem = (TGSelectableItem) spinner.getSelectedItem();
return (selectableItem != null ? ((Integer)selectableItem.getItem()).intValue() : 0);
}
示例11: selectCollection
import android.widget.Spinner; //导入方法依赖的package包/类
public TGBrowserCollection selectCollection() {
Spinner spinner = (Spinner) this.findViewById(R.id.browser_collections);
TGSelectableItem selectableItem = (TGSelectableItem) spinner.getSelectedItem();
return (selectableItem != null ? (TGBrowserCollection) selectableItem.getItem() : null);
}
示例12: findSelectedCollection
import android.widget.Spinner; //导入方法依赖的package包/类
public TGBrowserCollection findSelectedCollection() {
Spinner spinner = (Spinner) this.findViewById(R.id.browser_collections);
TGSelectableItem selectableItem = (TGSelectableItem) spinner.getSelectedItem();
return (selectableItem != null ? (TGBrowserCollection) selectableItem.getItem() : null);
}
示例13: findSelectedFormat
import android.widget.Spinner; //导入方法依赖的package包/类
public TGFileFormat findSelectedFormat() {
Spinner spinner = (Spinner) this.findViewById(R.id.browser_save_format);
TGSelectableItem selectableItem = (TGSelectableItem) spinner.getSelectedItem();
return (selectableItem != null ? (TGFileFormat) selectableItem.getItem() : null);
}
示例14: 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);
}
示例15: onDemandOnce
import android.widget.Spinner; //导入方法依赖的package包/类
private void onDemandOnce(PRestriction restriction, boolean category, PRestriction result, OnDemandResult oResult,
Spinner spOnce) {
oResult.once = true;
// Get duration
String value = (String) spOnce.getSelectedItem();
if (value == null)
result.time = new Date().getTime() + PrivacyManager.cRestrictionCacheTimeoutMs;
else {
char unit = value.charAt(value.length() - 1);
value = value.substring(0, value.length() - 1);
if (unit == 's')
result.time = new Date().getTime() + Integer.parseInt(value) * 1000;
else if (unit == 'm')
result.time = new Date().getTime() + Integer.parseInt(value) * 60 * 1000;
else
result.time = new Date().getTime() + PrivacyManager.cRestrictionCacheTimeoutMs;
try {
int userId = Util.getUserId(restriction.uid);
String sel = Integer.toString(spOnce.getSelectedItemPosition());
setSettingInternal(new PSetting(userId, "", PrivacyManager.cSettingODOnceDuration, sel));
} catch (Throwable ex) {
Util.bug(null, ex);
}
}
Util.log(null, Log.WARN, (result.restricted ? "Deny" : "Allow") + " once " + restriction + " category="
+ category + " until=" + new Date(result.time));
CRestriction key = new CRestriction(result, null);
key.setExpiry(result.time);
if (category) {
key.setMethodName(null);
key.setExtra(null);
}
synchronized (mAskedOnceCache) {
if (mAskedOnceCache.containsKey(key))
mAskedOnceCache.remove(key);
mAskedOnceCache.put(key, key);
}
}