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


Java Spinner.getAdapter方法代碼示例

本文整理匯總了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;
        }
    }
}
 
開發者ID:CMPUT301F17T15,項目名稱:CIA,代碼行數:23,代碼來源:HabitViewActivity.java

示例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;
        }
    }
}
 
開發者ID:rkkr,項目名稱:simple-keyboard,代碼行數:12,代碼來源:CustomInputStylePreference.java

示例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;
        }
    }
}
 
開發者ID:mkeresztes,項目名稱:AndiCar,代碼行數:15,代碼來源:BaseEditFragment.java

示例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);
}
 
開發者ID:axlecho,項目名稱:tuxguitar,代碼行數:6,代碼來源:TGBendDialog.java

示例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);
}
 
開發者ID:axlecho,項目名稱:tuxguitar,代碼行數:6,代碼來源:TGMeasureRemoveDialog.java

示例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);
}
 
開發者ID:axlecho,項目名稱:tuxguitar,代碼行數:6,代碼來源:TGTremoloBarDialog.java

示例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());
    }
}
 
開發者ID:umdcs,項目名稱:linkedout_procon,代碼行數:44,代碼來源:StudentModSettings.java

示例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);
}
 
開發者ID:guodroid,項目名稱:okwallet,代碼行數:73,代碼來源:WalletActivity.java


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