本文整理匯總了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);
}
示例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();
}
示例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));
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}