Java Code Examples for androidx.appcompat.widget.AppCompatSpinner#setOnItemSelectedListener()

The following examples show how to use androidx.appcompat.widget.AppCompatSpinner#setOnItemSelectedListener() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FilterView.java    From mimi-reader with Apache License 2.0 6 votes vote down vote up
private void init(Context context) {
    inflate(context, R.layout.post_filter_view, this);

    activeBoard = (AppCompatSpinner) findViewById(R.id.active_board);
    activeBoard.setOnItemSelectedListener(onBoardClicked());

    nameInput = (AppCompatEditText) findViewById(R.id.filter_name);
    filterInput = (AppCompatEditText) findViewById(R.id.filter_text);
    highlightCheckBox = (AppCompatCheckBox) findViewById(R.id.highlight_checkbox);

    saveButton = (AppCompatButton) findViewById(R.id.save_button);

    saveButton.setOnClickListener(this);
    findViewById(R.id.edit_button).setOnClickListener(this);
    findViewById(R.id.cancel_button).setOnClickListener(this);
}
 
Example 2
Source File: LiveWallpaperConfigActivity.java    From GeometricWeather with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void initView() {
    Toolbar toolbar = findViewById(R.id.activity_live_wallpaper_config_toolbar);
    toolbar.setNavigationIcon(R.drawable.ic_toolbar_back);
    toolbar.setNavigationOnClickListener(view -> finish());

    this.container = findViewById(R.id.activity_live_wallpaper_config_container);
    
    AppCompatSpinner weatherKindSpinner = findViewById(R.id.activity_live_wallpaper_config_weatherKindSpinner);
    weatherKindSpinner.setOnItemSelectedListener(new WeatherKindSpinnerSelectedListener());
    weatherKindSpinner.setAdapter(
            new ArrayAdapter<>(this, android.R.layout.simple_spinner_dropdown_item, weatherKinds)
    );
    weatherKindSpinner.setSelection(Arrays.binarySearch(weatherKindValues, weatherKindValueNow));

    AppCompatSpinner dayNightTypeSpinner = findViewById(R.id.activity_live_wallpaper_config_dayNightTypeSpinner);
    dayNightTypeSpinner.setOnItemSelectedListener(new DayNightTypeSpinnerSelectedListener());
    dayNightTypeSpinner.setAdapter(
            new ArrayAdapter<>(this, android.R.layout.simple_spinner_dropdown_item, dayNightTypes)
    );
    dayNightTypeSpinner.setSelection(Arrays.binarySearch(dayNightTypeValues, dayNightTypeValueNow));

    Button doneButton = findViewById(R.id.activity_live_wallpaper_config_doneButton);
    doneButton.setOnClickListener(v -> {
        LiveWallpaperConfigManager.update(
                this, weatherKindValueNow, dayNightTypeValueNow);
        finish();
    });
}
 
Example 3
Source File: HolyGraphActivity.java    From intra42 with Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_holy_graph);

    cursus = AppSettings.getAppCursus(app);
    campus = AppSettings.getAppCampus(app);

    Context context = this;
    ActionBar bar = getSupportActionBar();
    if (bar != null)
        context = bar.getThemedContext();
    SpinnerAdapter spinnerAdapter = ArrayAdapter.createFromResource(context,
            R.array.spinner_projects_galaxy, android.R.layout.simple_spinner_dropdown_item);

    spinner = new AppCompatSpinner(this);
    spinner.getBackground().setColorFilter(Color.parseColor("#ffffff"), PorterDuff.Mode.SRC_ATOP);
    spinner.setAdapter(spinnerAdapter);
    spinner.setOnItemSelectedListener(this);
    Toolbar.LayoutParams lp = new Toolbar.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    lp.setMarginStart((int) Tools.dpToPx(context, 8));
    spinner.setLayoutParams(lp);

    if (savedInstanceState != null)
        spinner.setSelection(savedInstanceState.getInt(STATE_POSITION));

    toolbar.addView(spinner);
    toolbar.setContentInsetStartWithNavigation((int) Tools.dpToPx(context, 8));

    listView = findViewById(R.id.listView);
    listViewAll = findViewById(R.id.listViewAll);
    textViewNoItem = findViewById(R.id.textViewNoItem);
    galaxy = findViewById(R.id.galaxy);

    galaxy.setOnProjectClickListener(this);
    listView.setOnItemClickListener(this);
    listViewAll.setOnItemClickListener(this);

    super.registerGetDataOnOtherThread(this);
    super.registerGetDataOnMainTread(this);
    super.setActionBarToggle(ActionBarToggle.HAMBURGER);
    super.setSelectedMenu(Navigation.MENU_SELECTED_PROJECTS);

    super.onCreateFinished();
}