当前位置: 首页>>代码示例>>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;未经允许,请勿转载。