Example usage for android.widget ArrayAdapter createFromResource

List of usage examples for android.widget ArrayAdapter createFromResource

Introduction

In this page you can find the example usage for android.widget ArrayAdapter createFromResource.

Prototype

public static @NonNull ArrayAdapter<CharSequence> createFromResource(@NonNull Context context,
        @ArrayRes int textArrayResId, @LayoutRes int textViewResId) 

Source Link

Document

Creates a new ArrayAdapter from external resources.

Usage

From source file:info.curtbinder.reefangel.phone.StatusActivity.java

private void setNavigationList() {
    // set list navigation items
    final ActionBar ab = getSupportActionBar();
    Context context = ab.getThemedContext();
    int arrayID;// w  ww  . j  a v  a  2  s .c  o m
    if (rapp.isAwayProfileEnabled()) {
        arrayID = R.array.profileLabels;
    } else {
        arrayID = R.array.profileLabelsHomeOnly;
    }
    ArrayAdapter<CharSequence> list = ArrayAdapter.createFromResource(context, arrayID,
            R.layout.support_simple_spinner_dropdown_item);
    list.setDropDownViewResource(R.layout.support_simple_spinner_dropdown_item);
    ab.setListNavigationCallbacks(list, this);
    ab.setSelectedNavigationItem(rapp.getSelectedProfile());
}

From source file:blackman.matt.boardlist.BoardListActivity.java

/**
 * Sets up the spinners on the view./* w w  w .j  ava2  s .  c  o m*/
 */
private void initSpinners() {
    Spinner spinnerSort;
    Spinner spinnerOrder;

    ArrayAdapter<CharSequence> sortAdapter;
    ArrayAdapter<CharSequence> orderAdapter;

    // Set up the spinners
    spinnerSort = (Spinner) findViewById(R.id.spinner_sort_by);
    spinnerOrder = (Spinner) findViewById(R.id.spinner_sort_order);

    sortAdapter = ArrayAdapter.createFromResource(this, R.array.sql_columns_array,
            android.R.layout.simple_spinner_item);

    orderAdapter = ArrayAdapter.createFromResource(this, R.array.sql_sort_order_array,
            android.R.layout.simple_spinner_item);

    sortAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    orderAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

    spinnerSort.setAdapter(sortAdapter);
    spinnerOrder.setAdapter(orderAdapter);

    spinnerOrder.setOnItemSelectedListener(new SpinnerActivity());
    spinnerSort.setOnItemSelectedListener(new SpinnerActivity());
}

From source file:de.azapps.mirakel.settings.model_settings.special_list.dialogfragments.EditDialogFragment.java

@Override
public View onCreateView(final LayoutInflater inflater, @Nullable final ViewGroup container,
        @Nullable final Bundle savedInstanceState) {
    final View rootView = inflater.inflate(R.layout.special_lists_edit_dialog_fragment, null);
    final ArrayAdapter<CharSequence> spinnerArrayAdapter = ArrayAdapter.createFromResource(getActivity(),
            R.array.special_lists_filter_type, android.R.layout.simple_spinner_dropdown_item);
    final Spinner spinner = (Spinner) rootView.findViewById(R.id.property_spinner);
    spinner.setAdapter(spinnerArrayAdapter);
    spinner.setOnItemSelectedListener(this);
    spinner.setSelection(propertyToType(property), false);
    handleNewFragment(propertyToType(property));
    final Button ok = (Button) rootView.findViewById(R.id.saveButton);
    ok.setOnClickListener(this);
    ((LinearLayout) rootView).setShowDividers(LinearLayout.SHOW_DIVIDER_END);
    return rootView;
}

From source file:com.h6ah4i.android.example.openslmediaplayer.app.contents.HQVisualizerFragment.java

private void setupViews() {
    HQVisualizerStateStore state = getStateStore();
    Context context = getActivity();

    mDuringSetupViews = true;//from   w  w  w.  j  ava 2  s .c o  m

    mToggleButtonEnableWaveform.setChecked(state.isCaptureWaveformEnabled());
    mToggleButtonEnableFft.setChecked(state.isCaptureFftEnabled());

    {
        final ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(context,
                R.array.hq_visualizer_window_type_names, android.R.layout.simple_spinner_item);
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        mSpinnerWindowType.setAdapter(adapter);
    }

    mSpinnerWindowType.setSelection(windowTypeToListPosition(state.getWindowType()));

    mDuringSetupViews = false;
}

From source file:com.amsterdam.marktbureau.makkelijkemarkt.DagvergunningFragmentKoopman.java

/**
 * Inflate the dagvergunning koopman fragment and initialize the view elements and its handlers
 * @param inflater//from   w w w  .  j  av a 2 s .  c  o  m
 * @param container
 * @param savedInstanceState
 * @return
 */
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View mainView = inflater.inflate(R.layout.dagvergunning_fragment_koopman, container, false);

    // bind the elements to the view
    ButterKnife.bind(this, mainView);

    // Create an onitemclick listener that will catch the clicked koopman from the autocomplete
    // lists (not using butterknife here because it does not support for @OnItemClick on
    // AutoCompleteTextView: https://github.com/JakeWharton/butterknife/pull/242
    AdapterView.OnItemClickListener autoCompleteItemClickListener = new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Cursor koopman = (Cursor) parent.getAdapter().getItem(position);

            // select the koopman and update the fragment
            selectKoopman(koopman.getInt(koopman.getColumnIndex(MakkelijkeMarktProvider.Koopman.COL_ID)),
                    KOOPMAN_SELECTION_METHOD_HANDMATIG);
        }
    };

    // create the custom cursor adapter that will query for an erkenningsnummer and show an autocomplete list
    ErkenningsnummerAdapter searchErkenningAdapter = new ErkenningsnummerAdapter(getContext());
    mErkenningsnummerEditText.setAdapter(searchErkenningAdapter);
    mErkenningsnummerEditText.setOnItemClickListener(autoCompleteItemClickListener);

    // create the custom cursor adapter that will query for a sollicitatienummer and show an autocomplete list
    SollicitatienummerAdapter searchSollicitatieAdapter = new SollicitatienummerAdapter(getContext());
    mSollicitatienummerEditText.setAdapter(searchSollicitatieAdapter);
    mSollicitatienummerEditText.setOnItemClickListener(autoCompleteItemClickListener);

    // disable uppercasing of the button text
    mScanBarcodeButton.setTransformationMethod(null);
    mScanNfcTagButton.setTransformationMethod(null);

    // get the aanwezig values from a resource array with aanwezig values
    mAanwezigKeys = getResources().getStringArray(R.array.array_aanwezig_key);

    // populate the aanwezig spinner from a resource array with aanwezig titles
    ArrayAdapter<CharSequence> aanwezigAdapter = ArrayAdapter.createFromResource(getContext(),
            R.array.array_aanwezig_title, android.R.layout.simple_spinner_dropdown_item);
    aanwezigAdapter.setDropDownViewResource(android.R.layout.simple_list_item_activated_1);
    mAanwezigSpinner.setAdapter(aanwezigAdapter);

    return mainView;
}

From source file:nl.sogeti.android.gpstracker.actions.ShareTrack.java

private void setGpxExportTargets() {
    ArrayAdapter<CharSequence> shareTargetAdapter = ArrayAdapter.createFromResource(this,
            R.array.sharegpxtarget_choices, android.R.layout.simple_spinner_item);
    shareTargetAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    mShareTargetSpinner.setAdapter(shareTargetAdapter);
    int lastTarget = PreferenceManager.getDefaultSharedPreferences(this).getInt(Constants.EXPORT_GPXTARGET,
            EXPORT_TARGET_SEND);//from   w  w w  .  ja va 2s . c  o  m
    mShareTargetSpinner.setSelection(lastTarget);
}

From source file:org.tvheadend.tvhclient.fragments.SeriesRecordingAddFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    if (channelName != null) {
        TVHClientApplication app = (TVHClientApplication) activity.getApplication();
        List<String> channels = new ArrayList<String>();
        for (Channel c : app.getChannels()) {
            channels.add(c.name);/*from  w  ww . j  ava  2s.  c  o m*/
        }
        ArrayAdapter<String> adapter = new ArrayAdapter<String>(activity, android.R.layout.simple_spinner_item,
                channels);
        channelName.setAdapter(adapter);
        channelName.setSelection(channelSelectionValue);
    }

    if (priority != null) {
        ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(activity, R.array.dvr_priorities,
                android.R.layout.simple_spinner_item);
        priority.setAdapter(adapter);
        priority.setSelection((int) priorityValue);
    }

    if (minDuration != null) {
        minDuration.setText(String.valueOf(minDurationValue));
    }
    if (maxDuration != null) {
        maxDuration.setText(String.valueOf(maxDurationValue));
    }
    if (startTime != null) {
        startTime.setText(String.valueOf(startTimeValue));
    }
    if (stopTime != null) {
        stopTime.setText(String.valueOf(stopTimeValue));
    }

    if (daysOfWeek != null) {
        MultiSpinnerListener msl = new MultiSpinnerListener() {
            @Override
            public void onItemsSelected(boolean[] checked) {
                daysOfWeekValue = daysOfWeek.getSpinnerValue();
            }
        };
        List<String> items = new ArrayList<String>(
                Arrays.asList(getResources().getStringArray(R.array.day_long_names)));
        List<String> textItems = new ArrayList<String>(
                Arrays.asList(getResources().getStringArray(R.array.day_short_names)));
        daysOfWeek.setItems(items, textItems, daysOfWeekValue, msl);
    }

    if (title != null) {
        title.setText(titleValue);
    }
    if (name != null) {
        name.setText(nameValue);
    }
    if (directory != null) {
        directory.setText(directoryValue);
    }
    if (retention != null) {
        retention.setText(String.valueOf(retentionValue));
    }
    if (isEnabled != null) {
        isEnabled.setChecked(enabledValue);
    }

    if (toolbar != null) {
        if (rec != null) {
            toolbar.setTitle((rec.name.length() > 0) ? rec.name : rec.title);
        }
        toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
            @Override
            public boolean onMenuItemClick(MenuItem item) {
                return onToolbarItemSelected(item);
            }
        });
        // Inflate a menu to be displayed in the toolbar
        toolbar.inflateMenu(R.menu.save_cancel_menu);
        toolbar.setTitle(R.string.add_recording);
    }
}

From source file:com.oldster.swiftmovedriver.fragment.EditCarFragment.java

private void loadDataCarDriver() {
    dataProvince = getResources().getStringArray(R.array.province);
    ArrayAdapter<CharSequence> adapterProvince = ArrayAdapter.createFromResource(getContext(), R.array.province,
            android.R.layout.simple_spinner_dropdown_item);
    mBind.spinnerProvince.setAdapter(adapterProvince);
    mBind.spinnerProvince.setOnItemSelectedListener(provincePlateListener);
    dataTypeCar = getResources().getStringArray(R.array.typeCar);
    ArrayAdapter<CharSequence> adapterTypeCar = ArrayAdapter.createFromResource(getContext(), R.array.typeCar,
            android.R.layout.simple_spinner_dropdown_item);
    mBind.spinnerTypeCar.setAdapter(adapterTypeCar);
    mBind.spinnerTypeCar.setOnItemSelectedListener(typeCarListener);
    for (int i = 0; i < dataTypeCar.length; i++) {
        if (dataTypeCar[i].equals(typeCarThai)) {
            mBind.spinnerTypeCar.setSelection(i);
            break;
        }/* w  w  w .  j a  v a  2 s. co m*/
    }
    for (int i = 0; i < dataProvince.length; i++) {
        if (dataProvince[i].equals(driver.getDriverDetailProvinceLicensePlate())) {
            mBind.spinnerProvince.setSelection(i);
            break;
        }
    }
    mBind.editTextModel.setText(driver.getDriverDetailModel());
    mBind.editTextBrand.setText(driver.getDriverDetailBrand());
    mBind.editTextColor.setText(driver.getDriverDetailColor());
    mBind.editTextPlateCar.setText(driver.getDriverDetailLicensePlate());

}

From source file:com.christophergs.mbientbasic.BothFragment.java

private void fillRangeAdapter() {
    ArrayAdapter<CharSequence> spinnerAdapter = null;
    if (accelModule instanceof Bmi160Accelerometer) {
        spinnerAdapter = ArrayAdapter.createFromResource(getActivity().getApplicationContext(),
                R.array.values_bmi160_acc_range, android.R.layout.simple_spinner_item);
    } else if (accelModule instanceof Mma8452qAccelerometer) {
        spinnerAdapter = ArrayAdapter.createFromResource(getActivity().getApplicationContext(),
                R.array.values_mma8452q_acc_range, android.R.layout.simple_spinner_item);
    }/*from  w  w w.  j  av a 2  s . com*/

    if (spinnerAdapter != null) {
        spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        accRangeSelection.setAdapter(spinnerAdapter);
    }
}

From source file:org.ozonecity.gpslogger2.GpsMainActivity.java

public void SetUpToolbar() {
    try {/*  w  w w  . j a  va 2  s . c  o m*/
        Toolbar toolbar = GetToolbar();
        setSupportActionBar(toolbar);
        getSupportActionBar().setDisplayShowTitleEnabled(false);

        //Deprecated in Lollipop but required if targeting 4.x
        SpinnerAdapter spinnerAdapter = ArrayAdapter.createFromResource(getApplicationContext(),
                R.array.gps_main_views, R.layout.spinner_dropdown_item);
        getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
        getSupportActionBar().setListNavigationCallbacks(spinnerAdapter, this);
        getSupportActionBar().setSelectedNavigationItem(GetUserSelectedNavigationItem());

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            Window window = getWindow();
            window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        }
    } catch (Exception ex) {
        //http://stackoverflow.com/questions/26657348/appcompat-v7-v21-0-0-causing-crash-on-samsung-devices-with-android-v4-2-2
        tracer.error("Thanks for this, Samsung", ex);
    }

}