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


Java AppCompatSpinner.setAdapter方法代碼示例

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


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

示例1: onCreate

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

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setNavigationIcon(R.drawable.ic_back);
    toolbar.setTitle(null);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            finish();
        }
    });

    AppCompatSpinner spinner = (AppCompatSpinner) findViewById(R.id.toolbarSpinner);
    ArrayAdapter<String> adapter = new ArrayAdapter<>(this, R.layout.list_item_spinner,
            new String[]{"One", "Two", "Three", "Four", "Five", "Six"});
    adapter.setDropDownViewResource(R.layout.list_item_spinner_dropdown);
    spinner.setAdapter(adapter);
}
 
開發者ID:deba12,項目名稱:app-theme-engine,代碼行數:22,代碼來源:MiscActivity.java

示例2: 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

示例3: 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

示例4: initWidget

import android.support.v7.widget.AppCompatSpinner; //導入方法依賴的package包/類
@Override
public void initWidget() {
    setWidgetView(true);

    ImageView wallpaper = findViewById(R.id.activity_create_widget_day_week_wall);
    wallpaper.setImageDrawable(WallpaperManager.getInstance(this).getDrawable());

    this.container = findViewById(R.id.activity_create_widget_day_week_container);

    AppCompatSpinner viewTypeSpinner = findViewById(R.id.activity_create_widget_day_week_styleSpinner);
    viewTypeSpinner.setOnItemSelectedListener(new ViewTypeSpinnerSelectedListener());
    viewTypeSpinner.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_spinner_dropdown_item, viewTypes));

    this.showCardSwitch = findViewById(R.id.activity_create_widget_day_week_showCardSwitch);
    showCardSwitch.setOnCheckedChangeListener(new ShowCardSwitchCheckListener());

    this.hideSubtitleSwitch = findViewById(R.id.activity_create_widget_day_week_hideSubtitleSwitch);
    hideSubtitleSwitch.setOnCheckedChangeListener(new HideRefreshTimeSwitchCheckListener());

    AppCompatSpinner subtitleDataSpinner = findViewById(R.id.activity_create_widget_day_week_subtitleDataSpinner);
    subtitleDataSpinner.setOnItemSelectedListener(new SubtitleDataSpinnerSelectedListener());
    subtitleDataSpinner.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_spinner_dropdown_item, subtitleData));

    this.blackTextSwitch = findViewById(R.id.activity_create_widget_day_week_blackTextSwitch);
    blackTextSwitch.setOnCheckedChangeListener(new BlackTextSwitchCheckListener());

    Button doneButton = findViewById(R.id.activity_create_widget_day_week_doneButton);
    doneButton.setOnClickListener(this);
}
 
開發者ID:WangDaYeeeeee,項目名稱:GeometricWeather,代碼行數:30,代碼來源:CreateWidgetDayWeekActivity.java

示例5: initWidget

import android.support.v7.widget.AppCompatSpinner; //導入方法依賴的package包/類
@Override
public void initWidget() {
    setWidgetView(true);

    ImageView wallpaper = findViewById(R.id.activity_create_widget_clock_day_vertical_wall);
    wallpaper.setImageDrawable(WallpaperManager.getInstance(this).getDrawable());

    this.container = findViewById(R.id.activity_create_widget_clock_day_vertical_container);

    AppCompatSpinner viewTypeSpinner = findViewById(R.id.activity_create_widget_clock_day_vertical_styleSpinner);
    viewTypeSpinner.setOnItemSelectedListener(new ViewTypeSpinnerSelectedListener());
    viewTypeSpinner.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_spinner_dropdown_item, viewTypes));

    this.showCardSwitch = findViewById(R.id.activity_create_widget_clock_day_vertical_showCardSwitch);
    showCardSwitch.setOnCheckedChangeListener(new ShowCardSwitchCheckListener());

    this.hideSubtitleSwitch = findViewById(R.id.activity_create_widget_clock_day_vertical_hideSubtitleSwitch);
    hideSubtitleSwitch.setOnCheckedChangeListener(new HideSubtitleSwitchCheckListener());

    AppCompatSpinner subtitleDataSpinner = findViewById(R.id.activity_create_widget_clock_day_vertical_subtitleDataSpinner);
    subtitleDataSpinner.setOnItemSelectedListener(new SubtitleDataSpinnerSelectedListener());
    subtitleDataSpinner.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_spinner_dropdown_item, subtitleData));

    this.blackTextSwitch = findViewById(R.id.activity_create_widget_clock_day_vertical_blackTextSwitch);
    blackTextSwitch.setOnCheckedChangeListener(new BlackTextSwitchCheckListener());

    Button doneButton = findViewById(R.id.activity_create_widget_clock_day_vertical_doneButton);
    doneButton.setOnClickListener(this);
}
 
開發者ID:WangDaYeeeeee,項目名稱:GeometricWeather,代碼行數:30,代碼來源:CreateWidgetClockDayVerticalActivity.java

示例6: initWidget

import android.support.v7.widget.AppCompatSpinner; //導入方法依賴的package包/類
@Override
public void initWidget() {
    setWidgetView(true);

    ImageView wallpaper = findViewById(R.id.activity_create_widget_day_wall);
    wallpaper.setImageDrawable(WallpaperManager.getInstance(this).getDrawable());

    this.container = findViewById(R.id.activity_create_widget_day_container);

    AppCompatSpinner viewTypeSpinner = findViewById(R.id.activity_create_widget_day_styleSpinner);
    viewTypeSpinner.setOnItemSelectedListener(new ViewTypeSpinnerSelectedListener());
    viewTypeSpinner.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_spinner_dropdown_item, viewTypes));

    this.showCardSwitch = findViewById(R.id.activity_create_widget_day_showCardSwitch);
    showCardSwitch.setOnCheckedChangeListener(new ShowCardSwitchCheckListener());

    this.hideSubtitleSwitch = findViewById(R.id.activity_create_widget_day_hideSubtitleSwitch);
    hideSubtitleSwitch.setOnCheckedChangeListener(new HideRefreshTimeSwitchCheckListener());

    AppCompatSpinner subtitleDataSpinner = findViewById(R.id.activity_create_widget_day_subtitleDataSpinner);
    subtitleDataSpinner.setOnItemSelectedListener(new SubtitleDataSpinnerSelectedListener());
    subtitleDataSpinner.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_spinner_dropdown_item, subtitleData));

    this.blackTextSwitch = findViewById(R.id.activity_create_widget_day_blackTextSwitch);
    blackTextSwitch.setOnCheckedChangeListener(new BlackTextSwitchCheckListener());

    Button doneButton = findViewById(R.id.activity_create_widget_day_doneButton);
    doneButton.setOnClickListener(this);
}
 
開發者ID:WangDaYeeeeee,項目名稱:GeometricWeather,代碼行數:30,代碼來源:CreateWidgetDayActivity.java

示例7: 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

示例8: populateElementsFromLayout

import android.support.v7.widget.AppCompatSpinner; //導入方法依賴的package包/類
@Override
protected void populateElementsFromLayout() {
    editName = (EditText) findViewById(R.id.name);
    editArduino = (AppCompatSpinner) findViewById(R.id.arduino);
    editArduino.setAdapter(new ArrayAdapter<>(this,
            android.R.layout.simple_spinner_item, getArduinoLists()));
    editType = (RadioGroup) findViewById(R.id.type);
    editTypeDigital = (RadioButton) findViewById(R.id.type_digital);
    editTypeAnalogical = (RadioButton) findViewById(R.id.type_analogical);
    editDirection = (RadioGroup) findViewById(R.id.direction);
    editDirectionInput = (RadioButton) findViewById(R.id.direction_input);
    editDirectionOutput = (RadioButton) findViewById(R.id.direction_output);
    editPort = (EditText) findViewById(R.id.port);
}
 
開發者ID:eduardoklosowski,項目名稱:Android-Arduino,代碼行數:15,代碼來源:SensorFormActivity.java

示例9: initializeFilterSpinner

import android.support.v7.widget.AppCompatSpinner; //導入方法依賴的package包/類
/**
 * Initializes the spinner for the download filter.
 * @param adapter The adapter associated with the spinner.
 */
public void initializeFilterSpinner(FilterAdapter adapter) {
    mSpinner = new AppCompatSpinner(this.getContext());
    mSpinner.setAdapter(adapter);
    mSpinner.setOnItemSelectedListener(adapter);
    addView(mSpinner);
}
 
開發者ID:mogoweb,項目名稱:365browser,代碼行數:11,代碼來源:DownloadManagerToolbar.java


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