Java Code Examples for android.widget.SpinnerAdapter#getCount()

The following examples show how to use android.widget.SpinnerAdapter#getCount() . 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: AlarmDialog.java    From SuntimesWidget with GNU General Public License v3.0 6 votes vote down vote up
public void setChoice( SolarEvents choice )
{
    if (choice != null)
    {
        this.choice = choice;
        if (spinner_scheduleMode != null)
        {
            SpinnerAdapter adapter = spinner_scheduleMode.getAdapter();
            if (adapter != null)
            {
                for (int i = 0; i < adapter.getCount(); i++)
                {
                    SolarEvents event = (SolarEvents) adapter.getItem(i);
                    if (event.equals(choice))
                    {
                        spinner_scheduleMode.setSelection(i);
                        break;
                    }
                }
            }
        }
    }
}
 
Example 2
Source File: ConnectionFragment.java    From octoandroid with GNU General Public License v3.0 5 votes vote down vote up
private void setSpinnerSelection(Spinner spinner, int position) {
    SpinnerAdapter adapter = spinner.getAdapter();
    if (adapter != null) {
        final int count = adapter.getCount();
        if (count > 0 && position < count) {
            spinner.setSelection(position, true);
        }
    }
}
 
Example 3
Source File: ActionBarImpl.java    From zhangshangwuda with Apache License 2.0 5 votes vote down vote up
@Override
public int getNavigationItemCount() {
    switch (mActionView.getNavigationMode()) {
        case NAVIGATION_MODE_TABS:
            return mTabs.size();
        case NAVIGATION_MODE_LIST:
            SpinnerAdapter adapter = mActionView.getDropdownAdapter();
            return adapter != null ? adapter.getCount() : 0;
        default:
            return 0;
    }
}
 
Example 4
Source File: ActionBarImpl.java    From zen4android with MIT License 5 votes vote down vote up
@Override
public int getNavigationItemCount() {
    switch (mActionView.getNavigationMode()) {
        case NAVIGATION_MODE_TABS:
            return mTabs.size();
        case NAVIGATION_MODE_LIST:
            SpinnerAdapter adapter = mActionView.getDropdownAdapter();
            return adapter != null ? adapter.getCount() : 0;
        default:
            return 0;
    }
}
 
Example 5
Source File: CustomInputStylePreference.java    From Indic-Keyboard with Apache License 2.0 5 votes vote down vote up
private static void setSpinnerPosition(final Spinner spinner, final Object itemToSelect) {
    final SpinnerAdapter adapter = spinner.getAdapter();
    final int count = adapter.getCount();
    for (int i = 0; i < count; i++) {
        final Object item = spinner.getItemAtPosition(i);
        if (item.equals(itemToSelect)) {
            spinner.setSelection(i);
            return;
        }
    }
}
 
Example 6
Source File: ActionBarImpl.java    From android-apps with MIT License 5 votes vote down vote up
@Override
public int getNavigationItemCount() {
    switch (mActionView.getNavigationMode()) {
        case NAVIGATION_MODE_TABS:
            return mTabs.size();
        case NAVIGATION_MODE_LIST:
            SpinnerAdapter adapter = mActionView.getDropdownAdapter();
            return adapter != null ? adapter.getCount() : 0;
        default:
            return 0;
    }
}
 
Example 7
Source File: DetailFragment.java    From kolabnotes-android with GNU Lesser General Public License v3.0 5 votes vote down vote up
void setSpinnerSelection(String notebookSummary){
    Spinner spinner = (Spinner) activity.findViewById(R.id.spinner_notebook);
    SpinnerAdapter adapter = spinner.getAdapter();
    for(int i=0;i<adapter.getCount();i++){
        String nbsummary = adapter.getItem(i).toString();
        if(nbsummary.equals(notebookSummary)){
            spinner.setSelection(i);
            break;
        }
    }
}
 
Example 8
Source File: FileSelectorActivity.java    From JotaTextEditor with Apache License 2.0 5 votes vote down vote up
private void selectItemOfSpinner( Spinner spinner , String s )
{
    SpinnerAdapter adapter = spinner.getAdapter();
    int max = adapter.getCount();
    for( int i=0;i<max;i++ ){
        String item = (String)adapter.getItem(i);
        if ( s.equals(item) ){
            spinner.setSelection(i);
            break;
        }
    }
    return;
}
 
Example 9
Source File: ActionBarImpl.java    From Libraries-for-Android-Developers with MIT License 5 votes vote down vote up
@Override
public int getNavigationItemCount() {
    switch (mActionView.getNavigationMode()) {
        case NAVIGATION_MODE_TABS:
            return mTabs.size();
        case NAVIGATION_MODE_LIST:
            SpinnerAdapter adapter = mActionView.getDropdownAdapter();
            return adapter != null ? adapter.getCount() : 0;
        default:
            return 0;
    }
}
 
Example 10
Source File: CustomInputStylePreference.java    From openboard with GNU General Public License v3.0 5 votes vote down vote up
private static void setSpinnerPosition(final Spinner spinner, final Object itemToSelect) {
    final SpinnerAdapter adapter = spinner.getAdapter();
    final int count = adapter.getCount();
    for (int i = 0; i < count; i++) {
        final Object item = spinner.getItemAtPosition(i);
        if (item.equals(itemToSelect)) {
            spinner.setSelection(i);
            return;
        }
    }
}
 
Example 11
Source File: RecurActivity.java    From financisto with GNU General Public License v2.0 5 votes vote down vote up
private void editRecur(Recur recur) {
    editStartDate(recur.startDate);
    RecurInterval interval = recur.interval;
    SpinnerAdapter adapter = sInterval.getAdapter();
    int count = adapter.getCount();
    for (int i = 0; i < count; i++) {
        SpinnerItem item = (SpinnerItem) adapter.getItem(i);
        if (interval == RecurInterval.valueOf(item.value)) {
            sInterval.setSelection(i);
            break;
        }
    }
    View v = selectInterval(interval);
    switch (interval) {
        case EVERY_X_DAY:
            editEveryXDay(v, recur);
            break;
        case WEEKLY:
            editWeekly(v, recur);
            break;
        case SEMI_MONTHLY:
            editSemiMonthly(v, recur);
            break;
    }
    RecurPeriod period = recur.period;
    sPeriod.setSelection(period.ordinal());
    v = selectPeriod(period);
    switch (period) {
        case EXACTLY_TIMES:
            editExactlyTimes(v, recur.periodParam);
            break;
        case STOPS_ON_DATE:
            editStopsOnDate(v, recur.periodParam);
            break;
    }
}
 
Example 12
Source File: CustomInputStylePreference.java    From AOSP-Kayboard-7.1.2 with Apache License 2.0 5 votes vote down vote up
private static void setSpinnerPosition(final Spinner spinner, final Object itemToSelect) {
    final SpinnerAdapter adapter = spinner.getAdapter();
    final int count = adapter.getCount();
    for (int i = 0; i < count; i++) {
        final Object item = spinner.getItemAtPosition(i);
        if (item.equals(itemToSelect)) {
            spinner.setSelection(i);
            return;
        }
    }
}
 
Example 13
Source File: CustomInputStylePreference.java    From simple-keyboard with Apache License 2.0 5 votes vote down vote up
private static void setLayoutSpinnerPosition(final Spinner spinner, final KeyboardLayoutSetItem itemToSelect) {
    final SpinnerAdapter adapter = spinner.getAdapter();
    final int count = adapter.getCount();
    for (int i = 0; i < count; i++) {
        final KeyboardLayoutSetItem item = (KeyboardLayoutSetItem)spinner.getItemAtPosition(i);
        if (item.mLayoutName.equals(itemToSelect.mLayoutName)) {
            spinner.setSelection(i);
            return;
        }
    }
}
 
Example 14
Source File: CustomInputStylePreference.java    From simple-keyboard with Apache License 2.0 5 votes vote down vote up
private static void setSubtypeSpinnerPosition(final Spinner spinner, final SubtypeLocaleItem itemToSelect) {
    final SpinnerAdapter adapter = spinner.getAdapter();
    final int count = adapter.getCount();
    for (int i = 0; i < count; i++) {
        final SubtypeLocaleItem item = (SubtypeLocaleItem)spinner.getItemAtPosition(i);
        if (item.mLocaleString.equals(itemToSelect.mLocaleString)) {
            spinner.setSelection(i);
            return;
        }
    }
}
 
Example 15
Source File: ActionBarImpl.java    From CSipSimple with GNU General Public License v3.0 5 votes vote down vote up
@Override
public int getNavigationItemCount() {
    switch (mActionView.getNavigationMode()) {
        case NAVIGATION_MODE_TABS:
            return mTabs.size();
        case NAVIGATION_MODE_LIST:
            SpinnerAdapter adapter = mActionView.getDropdownAdapter();
            return adapter != null ? adapter.getCount() : 0;
        default:
            return 0;
    }
}
 
Example 16
Source File: FileSelectorActivity.java    From PowerFileExplorer with GNU General Public License v3.0 5 votes vote down vote up
private void selectItemOfSpinner( Spinner spinner , String s )
{
    SpinnerAdapter adapter = spinner.getAdapter();
    int max = adapter.getCount();
    for( int i=0;i<max;i++ ){
        String item = (String)adapter.getItem(i);
        if ( s.equals(item) ){
            spinner.setSelection(i);
            break;
        }
    }
    return;
}
 
Example 17
Source File: CustomInputStylePreference.java    From LokiBoard-Android-Keylogger with Apache License 2.0 5 votes vote down vote up
private static void setLayoutSpinnerPosition(final Spinner spinner, final KeyboardLayoutSetItem itemToSelect) {
    final SpinnerAdapter adapter = spinner.getAdapter();
    final int count = adapter.getCount();
    for (int i = 0; i < count; i++) {
        final KeyboardLayoutSetItem item = (KeyboardLayoutSetItem)spinner.getItemAtPosition(i);
        if (item.mLayoutName.equals(itemToSelect.mLayoutName)) {
            spinner.setSelection(i);
            return;
        }
    }
}
 
Example 18
Source File: CustomInputStylePreference.java    From LokiBoard-Android-Keylogger with Apache License 2.0 5 votes vote down vote up
private static void setSubtypeSpinnerPosition(final Spinner spinner, final SubtypeLocaleItem itemToSelect) {
    final SpinnerAdapter adapter = spinner.getAdapter();
    final int count = adapter.getCount();
    for (int i = 0; i < count; i++) {
        final SubtypeLocaleItem item = (SubtypeLocaleItem)spinner.getItemAtPosition(i);
        if (item.mLocaleString.equals(itemToSelect.mLocaleString)) {
            spinner.setSelection(i);
            return;
        }
    }
}
 
Example 19
Source File: CustomInputStylePreference.java    From Android-Keyboard with Apache License 2.0 5 votes vote down vote up
private static void setSpinnerPosition(final Spinner spinner, final Object itemToSelect) {
    final SpinnerAdapter adapter = spinner.getAdapter();
    final int count = adapter.getCount();
    for (int i = 0; i < count; i++) {
        final Object item = spinner.getItemAtPosition(i);
        if (item.equals(itemToSelect)) {
            spinner.setSelection(i);
            return;
        }
    }
}
 
Example 20
Source File: SpinnerHelper.java    From AndroidAPS with GNU Affero General Public License v3.0 4 votes vote down vote up
public void setAdapter(SpinnerAdapter adapter) {
    if (adapter.getCount() > 0) {
        lastPosition = 0;
    }
    spinner.setAdapter(adapter);
}