當前位置: 首頁>>代碼示例>>Java>>正文


Java Spinner.getSelectedItemPosition方法代碼示例

本文整理匯總了Java中android.widget.Spinner.getSelectedItemPosition方法的典型用法代碼示例。如果您正苦於以下問題:Java Spinner.getSelectedItemPosition方法的具體用法?Java Spinner.getSelectedItemPosition怎麽用?Java Spinner.getSelectedItemPosition使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.widget.Spinner的用法示例。


在下文中一共展示了Spinner.getSelectedItemPosition方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onItemSelected

import android.widget.Spinner; //導入方法依賴的package包/類
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
    Spinner sp = (Spinner) parent;
    int i = sp.getSelectedItemPosition();
    switch (sp.getId()) {
        case R.id.spnAutoHobbs:
            MFBLocation.fPrefAutoFillHobbs = MFBLocation.AutoFillOptions.values()[i];
            break;
        case R.id.spnAutoTime:
            MFBLocation.fPrefAutoFillTime = MFBLocation.AutoFillOptions.values()[i];
            break;
        case R.id.spnTOSpeed:
            MFBTakeoffSpeed.setTakeOffSpeedIndex(i);
            break;
        default:
            break;
    }
}
 
開發者ID:ericberman,項目名稱:MyFlightbookAndroid,代碼行數:18,代碼來源:ActOptions.java

示例2: refreshCollections

import android.widget.Spinner; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
public void refreshCollections() {
	ArrayAdapter<TGSelectableItem> arrayAdapter = new ArrayAdapter<TGSelectableItem>(findActivity(), R.layout.view_browser_spinner_item, createCollectionValues());
	arrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
	
	TGSelectableItem selectedItem = new TGSelectableItem(findCurrentCollection(), null);
	Integer selectedItemPosition = arrayAdapter.getPosition(selectedItem);
	
	Spinner spinner = (Spinner) this.findViewById(R.id.browser_collections);
	OnItemSelectedListener listener = spinner.getOnItemSelectedListener();
	spinner.setOnItemSelectedListener(null);
	if(!this.isSameCollection(arrayAdapter, (ArrayAdapter<TGSelectableItem>) spinner.getAdapter())) {
		spinner.setAdapter(arrayAdapter);
	}
	if( spinner.getSelectedItemPosition() != selectedItemPosition ) {
		spinner.setSelection(selectedItemPosition, false);
	}
	spinner.setOnItemSelectedListener(listener);
}
 
開發者ID:axlecho,項目名稱:tuxguitar,代碼行數:20,代碼來源:TGBrowserView.java

示例3: startClick

import android.widget.Spinner; //導入方法依賴的package包/類
public void startClick(View v) {
    TestParams params = new TestParams();
    Spinner spinnerThread = (Spinner) findViewById(R.id.spinnerThread);
    String threadModeStr = spinnerThread.getSelectedItem().toString();
    ThreadMode threadMode = ThreadMode.valueOf(threadModeStr);
    params.setThreadMode(threadMode);

    params.setEventInheritance(((CheckBox) findViewById(R.id.checkBoxEventBusEventHierarchy)).isChecked());
    params.setIgnoreGeneratedIndex(((CheckBox) findViewById(R.id.checkBoxEventBusIgnoreGeneratedIndex)).isChecked());

    EditText editTextEvent = (EditText) findViewById(R.id.editTextEvent);
    params.setEventCount(Integer.parseInt(editTextEvent.getText().toString()));

    EditText editTextSubscriber = (EditText) findViewById(R.id.editTextSubscribe);
    params.setSubscriberCount(Integer.parseInt(editTextSubscriber.getText().toString()));

    Spinner spinnerTestToRun = (Spinner) findViewById(R.id.spinnerTestToRun);
    int testPos = spinnerTestToRun.getSelectedItemPosition();
    params.setTestNumber(testPos + 1);
    ArrayList<Class<? extends Test>> testClasses = initTestClasses(testPos);
    params.setTestClasses(testClasses);

    Intent intent = new Intent();
    intent.setClass(this, TestRunnerActivity.class);
    intent.putExtra("params", params);
    startActivity(intent);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:28,代碼來源:TestSetupActivity.java

示例4: categoryButtonListener

import android.widget.Spinner; //導入方法依賴的package包/類
public void categoryButtonListener(View v) {
    Spinner categorySpinner = (Spinner) findViewById(R.id.category_spinner);
    TextView categoryValidation = (TextView) findViewById(R.id.category_validation);
    if (categorySpinner.getSelectedItemPosition() == categorySpinner.getCount()) {
        categoryValidation.setVisibility(View.VISIBLE);
    } else {
        categoryValidation.setVisibility(View.INVISIBLE);
        int categoryId =
                ((Spinner) findViewById(R.id.category_spinner)).getSelectedItemPosition();
        mCategory = Category.values()[categoryId];
        nextPage();
    }
}
 
開發者ID:ArnauBlanch,項目名稱:civify-app,代碼行數:14,代碼來源:CreateIssueActivity.java

示例5: onItemSelected

import android.widget.Spinner; //導入方法依賴的package包/類
@Override
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
    Spinner spinner = (Spinner) parent;
    mSelectedMovie = spinner.getSelectedItemPosition();

    Log.d(TAG, "onItemSelected: " + mSelectedMovie + " '" + mMovieFiles[mSelectedMovie] + "'");
}
 
開發者ID:AndyZhu1991,項目名稱:grafika,代碼行數:8,代碼來源:PlayMovieActivity.java

示例6: onItemSelected

import android.widget.Spinner; //導入方法依賴的package包/類
@Override
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
    Spinner spinner = (Spinner) parent;
    final int filterNum = spinner.getSelectedItemPosition();

    Log.d(TAG, "onItemSelected: " + filterNum);
    mGLView.queueEvent(new Runnable() {
        @Override public void run() {
            // notify the renderer that we want to change the encoder's state
            mRenderer.changeFilterMode(filterNum);
        }
    });
}
 
開發者ID:AndyZhu1991,項目名稱:grafika,代碼行數:14,代碼來源:CameraCaptureActivity.java

示例7: onItemSelected

import android.widget.Spinner; //導入方法依賴的package包/類
@Override
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
    Spinner spinner = (Spinner) parent;
    final int selIndex = spinner.getSelectedItemPosition();
    boolean updated = false;

    if (parent.getId() == R.id.scheduledSwapUpdate_spinner) {
        if (mUpdatePatternIndex != selIndex) {
            Log.d(TAG, "onItemSelected [update-rate]: " + selIndex);
            mUpdatePatternIndex = selIndex;
            updated = true;
        }
    } else if (parent.getId() == R.id.scheduledSwapAhead_spinner) {
        if (mFramesAheadIndex != selIndex) {
            Log.d(TAG, "onItemSelected [frames-ahead]: " + selIndex);
            mFramesAheadIndex = selIndex;
            updated = true;
        }
    } else {
        throw new RuntimeException("Unknown spinner");
    }

    if (mRenderThread == null) {
        // huh
        Log.d(TAG, "In onItemSelected while the activity is paused");
    } else if (updated) {
        RenderHandler rh = mRenderThread.getHandler();
        if (rh != null) {
            rh.sendSetParameters(mUpdatePatternIndex, mFramesAheadIndex);
        }
    }
}
 
開發者ID:AndyZhu1991,項目名稱:grafika,代碼行數:33,代碼來源:ScheduledSwapActivity.java

示例8: getNumberType

import android.widget.Spinner; //導入方法依賴的package包/類
private int getNumberType(View row) {
    Spinner numberTypeSpinner = (Spinner) row.findViewById(R.id.spinner_number_type);
    switch (numberTypeSpinner.getSelectedItemPosition()) {
        case 1:
            return ContactNumber.TYPE_CONTAINS;
        case 2:
            return ContactNumber.TYPE_STARTS;
        case 3:
            return ContactNumber.TYPE_ENDS;
    }

    return ContactNumber.TYPE_EQUALS;
}
 
開發者ID:kaliturin,項目名稱:BlackList,代碼行數:14,代碼來源:AddOrEditContactFragment.java

示例9: onItemSelected

import android.widget.Spinner; //導入方法依賴的package包/類
public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2,
                           long arg3) {
    saveLastTail();
    Spinner sp = (Spinner) findViewById(R.id.spnAircraftType);
    m_ac.InstanceTypeID = sp.getSelectedItemPosition() + 1;
    toView();
}
 
開發者ID:ericberman,項目名稱:MyFlightbookAndroid,代碼行數:8,代碼來源:ActNewAircraft.java

示例10: putPref

import android.widget.Spinner; //導入方法依賴的package包/類
private void putPref(SharedPreferences.Editor prefsEditor, Spinner spinner, int id, String key) {
    int position = spinner.getSelectedItemPosition();
    String selectedString = getResources().obtainTypedArray(id).getString(position);
    // Save to preferences the value selected in the spinner
    prefsEditor.putString(key, selectedString);
}
 
開發者ID:dftec-es,項目名稱:planetcon,代碼行數:7,代碼來源:StartActivity.java

示例11: doInBackground

import android.widget.Spinner; //導入方法依賴的package包/類
@Override
protected Throwable doInBackground(String... params) {
	// Get wakelock
	PowerManager pm = (PowerManager) ActivityShare.this.getSystemService(Context.POWER_SERVICE);
	PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "XPrivacy.Toggle");
	wl.acquire();
	try {
		// Get data
		mProgressCurrent = 0;
		List<Integer> lstUid = mAppAdapter.getListUid();
		final String restrictionName = params[0];
		int actionId = ((RadioGroup) ActivityShare.this.findViewById(R.id.rgToggle)).getCheckedRadioButtonId();
		Spinner spTemplate = ((Spinner) ActivityShare.this.findViewById(R.id.spTemplate));
		String templateName = Meta.cTypeTemplate;
		if (spTemplate.getSelectedItemPosition() > 0)
			templateName = Meta.cTypeTemplate + spTemplate.getSelectedItemPosition();

		for (Integer uid : lstUid)
			try {
				if (mAbort)
					throw new AbortException(ActivityShare.this);

				// Update progess
				publishProgress(++mProgressCurrent, lstUid.size() + 1);
				setState(uid, STATE_RUNNING, null);

				List<Boolean> oldState = PrivacyManager.getRestartStates(uid, restrictionName);

				if (actionId == R.id.rbClear) {
					PrivacyManager.deleteRestrictions(uid, restrictionName, (restrictionName == null));
					if (restrictionName == null) {
						PrivacyManager.deleteUsage(uid);
						PrivacyManager.deleteSettings(uid);
					}
				}

				else if (actionId == R.id.rbRestrict) {
					PrivacyManager.setRestriction(uid, restrictionName, null, true, false);
					PrivacyManager.updateState(uid);
				}

				else if (actionId == R.id.rbTemplateCategory)
					PrivacyManager.applyTemplate(uid, templateName, restrictionName, false, true, false);

				else if (actionId == R.id.rbTemplateFull)
					PrivacyManager.applyTemplate(uid, templateName, restrictionName, true, true, false);

				else if (actionId == R.id.rbTemplateMergeSet)
					PrivacyManager.applyTemplate(uid, templateName, restrictionName, true, false, false);

				else if (actionId == R.id.rbTemplateMergeReset)
					PrivacyManager.applyTemplate(uid, templateName, restrictionName, true, false, true);

				else if (actionId == R.id.rbEnableOndemand) {
					PrivacyManager.setSetting(uid, PrivacyManager.cSettingOnDemand, Boolean.toString(true));
					PrivacyManager.setSetting(uid, PrivacyManager.cSettingNotify, Boolean.toString(false));

				} else if (actionId == R.id.rbDisableOndemand) {
					PrivacyManager.setSetting(uid, PrivacyManager.cSettingOnDemand, Boolean.toString(false));
					PrivacyManager.setSetting(uid, PrivacyManager.cSettingNotify, Boolean.toString(true));

				} else
					Util.log(null, Log.ERROR, "Unknown action=" + actionId);

				List<Boolean> newState = PrivacyManager.getRestartStates(uid, restrictionName);

				setState(uid, STATE_SUCCESS, !newState.equals(oldState) ? getString(R.string.msg_restart)
						: null);
			} catch (Throwable ex) {
				setState(uid, STATE_FAILURE, ex.getMessage());
				return ex;
			}
	} finally {
		wl.release();
	}

	return null;
}
 
開發者ID:ukanth,項目名稱:XPrivacy,代碼行數:79,代碼來源:ActivityShare.java


注:本文中的android.widget.Spinner.getSelectedItemPosition方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。