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


Java AppCompatSpinner.setSelection方法代碼示例

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


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

示例1: onCreate

import android.support.v7.widget.AppCompatSpinner; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.sample_activity);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    mSpinnerDelay = (AppCompatSpinner) findViewById(R.id.spinner_delay);
    mSpinnerSlide = (AppCompatSpinner) findViewById(R.id.spinner_slide);
    mSpinnerDelay.setAdapter(new ArrayAdapter<>(this, R.layout.spinner, mDelayGravities));
    mSpinnerSlide.setAdapter(new ArrayAdapter<>(this, R.layout.spinner, mSlideGravities));
    mSpinnerDelay.setSelection(1);
    mSpinnerSlide.setSelection(1);
    mSpinnerDelay.setOnItemSelectedListener(this);
    mSpinnerSlide.setOnItemSelectedListener(this);

    mRecyclerView = (RecyclerView) findViewById(R.id.recycler_view);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
    mRecyclerView.setAdapter(new Adapter());
    startMaterialIn();
}
 
開發者ID:andkulikov,項目名稱:Material-In,代碼行數:22,代碼來源:SampleActivity.java

示例2: setupLanguageSelect

import android.support.v7.widget.AppCompatSpinner; //導入方法依賴的package包/類
void setupLanguageSelect(final Context context, final View view) {
    AppCompatSpinner spinner = (AppCompatSpinner) view.findViewById(R.id.languageSpinner);

    List<String> selections = new ArrayList<>();
    selections.add(getResources().getString(R.string.Finnish));
    selections.add(getResources().getString(R.string.Swedish));
    selections.add(getResources().getString(R.string.English));

    ArrayAdapter<String> adapter = new ArrayAdapter<>(this.getActivity(), R.layout.setting_spinner_item, selections);
    adapter.setDropDownViewResource(R.layout.setting_spinner_dropdown_item);

    spinner.setAdapter(adapter);

    String languageSetting = AppPreferences.getLanguageCodeSetting(context);
    switch (languageSetting) {
        case AppPreferences.LANGUAGE_CODE_FI:
            spinner.setSelection(0);
            break;
        case AppPreferences.LANGUAGE_CODE_SV:
            spinner.setSelection(1);
            break;
        default: // "en"
            spinner.setSelection(2);
            break;
    }

    spinner.setOnItemSelectedListener(new LanguageSelectedListener(context));
}
 
開發者ID:suomenriistakeskus,項目名稱:oma-riista-android,代碼行數:29,代碼來源:SettingsFragment.java

示例3: setupView

import android.support.v7.widget.AppCompatSpinner; //導入方法依賴的package包/類
@Override
public void setupView(View view) {
    AppCompatSpinner spinner = (AppCompatSpinner)view.findViewById(R.id.settings_spinner);
    spinner.setAdapter(adapter);
    spinner.setOnItemSelectedListener(onItemSelectedListener);
    if (selectedPos != -1)
        spinner.setSelection(selectedPos);
}
 
開發者ID:PuffOpenSource,項目名稱:Puff-Android,代碼行數:9,代碼來源:SelectorItem.java

示例4: onCreateDialog

import android.support.v7.widget.AppCompatSpinner; //導入方法依賴的package包/類
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final Context context = getActivity();

    final AlertDialog.Builder builder = new AlertDialog.Builder(context);
    final LayoutInflater dialogInflater = getActivity().getLayoutInflater();

    final View view = dialogInflater.inflate(R.layout.dialog_create_connection, null, false);
    name = (AppCompatEditText) view.findViewById(R.id.name);
    host = (AppCompatEditText) view.findViewById(R.id.host);
    port = (AppCompatEditText) view.findViewById(R.id.port);
    path = (AppCompatEditText) view.findViewById(R.id.path);
    hostContainer = view.findViewById(R.id.hostContainer);
    pathContainer = view.findViewById(R.id.pathContainer);
    username = (AppCompatEditText) view.findViewById(R.id.username);
    usernameContainer = view.findViewById(R.id.usernameContainer);
    password = (AppCompatEditText) view.findViewById(R.id.password);
    passwordContainer = view.findViewById(R.id.passwordContainer);
    scheme = (AppCompatSpinner) view.findViewById(R.id.scheme);
    anonymous = (AppCompatCheckBox) view.findViewById(R.id.anonymous);
    anonymous.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
            usernameContainer.setVisibility(b ? View.GONE : View.VISIBLE);
            passwordContainer.setVisibility(b ? View.GONE : View.VISIBLE);
        }
    });

    if(connection_id != 0){
        NetworkConnection connection =
                NetworkConnection.fromConnectionId(getActivity(), connection_id);

        ArrayAdapter myAdap = (ArrayAdapter) scheme.getAdapter();
        int spinnerPosition = myAdap.getPosition(connection.getScheme().toUpperCase());
        scheme.setSelection(spinnerPosition);

        name.setText(connection.getName());
        host.setText(connection.getHost());
        port.setText(Integer.toString(connection.getPort()));
        path.setText(connection.getPath());
        username.setText(connection.getUserName());
        password.setText(connection.getPassword());
        anonymous.setChecked(connection.isAnonymousLogin());
        if(SERVER.equals(connection.getType())){
            hostContainer.setVisibility(View.GONE);
            pathContainer.setVisibility(View.VISIBLE);
        }
    }
    builder.setTitle( (connection_id == 0 ? "New" : "Edit") + " Connection");
    builder.setView(view);

    builder.setPositiveButton(connection_id == 0 ? "ADD" : "SAVE", new OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            final BaseActivity activity = (BaseActivity) getActivity();

            NetworkConnection networkConnection = getNetworkConnection();
            if(validate(networkConnection)){
                new CreateConnectionTask(activity, networkConnection).executeOnExecutor(
                        ProviderExecutor.forAuthority(ExplorerProvider.AUTHORITY));
            }

        }
    });
    builder.setNegativeButton(android.R.string.cancel, null);

    return builder.create();
}
 
開發者ID:kranthi0987,項目名稱:easyfilemanager,代碼行數:69,代碼來源:CreateConnectionFragment.java

示例5: setSelectedItemPosition

import android.support.v7.widget.AppCompatSpinner; //導入方法依賴的package包/類
@BindingAdapter("selectedItemPosition")
public void setSelectedItemPosition(AppCompatSpinner spinner,int position)
{
    if(spinner.getSelectedItemPosition()!=position)
        spinner.setSelection(position);
}
 
開發者ID:Orange-OpenSource,項目名稱:OCast-Java,代碼行數:7,代碼來源:ViewModel.java


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