Java Code Examples for android.widget.AdapterView#getSelectedItemPosition()

The following examples show how to use android.widget.AdapterView#getSelectedItemPosition() . 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: SuntimesConfigActivity0.java    From SuntimesWidget with GNU General Public License v3.0 6 votes vote down vote up
public void onItemSelected(AdapterView<?> parent, View view, int position, long id)
{
    final WidgetSettings.ActionMode[] actionModes = WidgetSettings.ActionMode.values();
    WidgetSettings.ActionMode actionMode = actionModes[parent.getSelectedItemPosition()];

    View launchActionView = findViewById(R.id.applayout_action_launch);
    if (launchActionView != null)
    {
        switch (actionMode)
        {
            case ONTAP_LAUNCH_ACTIVITY:
                launchActionView.setVisibility(View.VISIBLE);
                break;

            case ONTAP_DONOTHING:
            default:
                launchActionView.setVisibility(View.GONE);
                break;
        }
    }
}
 
Example 2
Source File: TimeZoneDialog.java    From SuntimesWidget with GNU General Public License v3.0 6 votes vote down vote up
public void onItemSelected(AdapterView<?> parent, View view, int position, long id)
{
    spinner_timezone.setOnItemSelectedListener(null);
    spinner_solartime.setOnItemSelectedListener(null);

    final WidgetSettings.TimezoneMode[] timezoneModes = WidgetSettings.TimezoneMode.values();
    WidgetSettings.TimezoneMode timezoneMode = timezoneModes[parent.getSelectedItemPosition()];

    boolean useSolarTime = (timezoneMode == WidgetSettings.TimezoneMode.SOLAR_TIME);
    if (useSolarTime)
        spinner_solartime.setOnItemSelectedListener(onSolarTimeSelected);
    else spinner_timezone.setOnItemSelectedListener(onTimeZoneSelected);

    if (timezoneMode == WidgetSettings.TimezoneMode.CUSTOM_TIMEZONE) {
        customTimezoneID = WidgetSettings.loadTimezonePref(getContext(), appWidgetId, SLOT_CUSTOM0);
    }
    setUseCustomTimezone((timezoneMode == WidgetSettings.TimezoneMode.CUSTOM_TIMEZONE));
    setUseSolarTime((timezoneMode == WidgetSettings.TimezoneMode.SOLAR_TIME));

    Object item = (useSolarTime ? spinner_solartime.getSelectedItem() : spinner_timezone.getSelectedItem());
    updateExtras(getContext(), useSolarTime, item);

    SuntimesUtils.announceForAccessibility(spinner_timezoneMode, timezoneMode.getDisplayString());
}
 
Example 3
Source File: SuntimesConfigActivity0.java    From SuntimesWidget with GNU General Public License v3.0 5 votes vote down vote up
public void onItemSelected(AdapterView<?> parent, View view, int position, long id)
{
    final WidgetSettings.TimezoneMode[] timezoneModes = WidgetSettings.TimezoneMode.values();
    WidgetSettings.TimezoneMode timezoneMode = timezoneModes[parent.getSelectedItemPosition()];
    setCustomTimezoneEnabled((timezoneMode == WidgetSettings.TimezoneMode.CUSTOM_TIMEZONE));
    setUseSolarTime((timezoneMode == WidgetSettings.TimezoneMode.SOLAR_TIME));
}