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:com.pawnua.android.app.licenseplates.MainActivity.java

private void setUpSpinner() {
    spinner = (Spinner) findViewById(R.id.spinner_nav);
    spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override//from w  w w .j a  v a  2s .c  o  m
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            spinnerPosition = position;
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {

        }
    });

    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(toolbar.getContext(),
            R.array.submenu_array, R.layout.spinner_dropdown_item);
    adapter.setDropDownViewResource(R.layout.spinner_dropdown_item);

    spinner.setAdapter(adapter);
}

From source file:com.anton.gavel.PersonalInfoDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());

    LayoutInflater inflater = getActivity().getLayoutInflater();
    dialogView = inflater.inflate(R.layout.dialog_personal_info, null);

    Spinner spinner = (Spinner) dialogView.findViewById(R.id.personal_cities_spinner);
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(getActivity(), R.array.cities,
            android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(adapter);/*from w w  w . j ava2s . c o  m*/

    builder.setView(dialogView).setTitle("Personal Information")
            .setPositiveButton("Ok", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int id) {
                    mListener.onDialogPositiveClick(PersonalInfoDialogFragment.this);
                }
            }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    PersonalInfoDialogFragment.this.getDialog().cancel();
                }
            });
    populatePersonalInfo();
    return builder.create();
}

From source file:com.example.travelclaims.NewExpenseActivity.java

protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.addnewexpense);

    DateView = (EditText) findViewById(R.id.editDate);

    final Spinner categoryspinner = (Spinner) findViewById(R.id.categoryspinner);
    ArrayAdapter<CharSequence> categoryadapter = ArrayAdapter.createFromResource(this, R.array.category_array,
            android.R.layout.simple_spinner_item);
    categoryadapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    categoryspinner.setAdapter(categoryadapter);

    final Spinner currencyspinner = (Spinner) findViewById(R.id.currencyspinner);
    ArrayAdapter<CharSequence> currencyadapter = ArrayAdapter.createFromResource(this, R.array.currency_array,
            android.R.layout.simple_spinner_item);
    currencyadapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    currencyspinner.setAdapter(currencyadapter);

    currencyspinner.setOnItemSelectedListener(new OnItemSelectedListener() {

        @Override/*www .ja  v a  2s .c o m*/
        public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
            currency = currencyspinner.getSelectedItem().toString();

        }

        @Override
        public void onNothingSelected(AdapterView<?> arg0) {
            // TODO Auto-generated method stub

        }
    });
    categoryspinner.setOnItemSelectedListener(new OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
            category = categoryspinner.getSelectedItem().toString();

        }

        @Override
        public void onNothingSelected(AdapterView<?> arg0) {
            // TODO Auto-generated method stub

        }
    });

    set_on_click();

}

From source file:br.com.frs.foodrestrictions.MessageLanguageSelector.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.activity_message_lang_selector, container, false);

    ArrayAdapter arrayAdapter = ArrayAdapter.createFromResource(v.getContext(),
            R.array.languages_messages_array, android.R.layout.simple_list_item_1);

    setListAdapter(arrayAdapter);/*w w  w  .  j  a va 2s.c om*/

    return v;
}

From source file:edu.asu.msse.dssoni.moviedescrpitionapp.AddActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_add);
    spinner = (Spinner) findViewById(R.id.spinner);
    arrayAdapter = ArrayAdapter.createFromResource(this, R.array.genre, android.R.layout.simple_spinner_item);
    arrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(arrayAdapter);//from  ww  w.  j  av a  2 s .c  o m
}

From source file:com.uwetrottmann.movies.ui.MoviesActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.movies_activity);

    final ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayShowTitleEnabled(false);
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
    ArrayAdapter<CharSequence> mActionBarList = ArrayAdapter.createFromResource(this, R.array.movie_lists,
            R.layout.sherlock_spinner_item);
    mActionBarList.setDropDownViewResource(R.layout.sherlock_spinner_dropdown_item);
    actionBar.setListNavigationCallbacks(mActionBarList, this);

    // try to restore previously set nav item
    final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    final int navItem = prefs.getInt(AppPreferences.KEY_NAVSELECTION, 0);
    actionBar.setSelectedNavigationItem(navItem);
}

From source file:org.deviceconnect.android.uiapp.fragment.profile.NotificationProfileFragment.java

@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
        final Bundle savedInstanceState) {
    mLogger.entering(getClass().getName(), "onCreateView",
            new Object[] { inflater, container, savedInstanceState });

    View view = inflater.inflate(R.layout.fragment_notification_service, container, false);
    view.setBackgroundColor(getResources().getColor(android.R.color.background_light));

    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(getActivity(),
            R.array.notification_type_list, android.R.layout.simple_spinner_item);
    mSpinner = (Spinner) view.findViewById(R.id.fragment_notification_service_type);
    mSpinner.setAdapter(adapter);// w  w w.  j  ava2 s. com

    Button sendButton = (Button) view.findViewById(R.id.fragment_notification_service_send);
    sendButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(final View view) {
            onClickSend(view);
        }
    });

    mLogger.exiting(getClass().getName(), "onCreateView", view);
    return view;
}

From source file:se.hockersten.timed.vibration.main.PracticeTab.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    root = inflater.inflate(R.layout.main_practice, container, false);

    Spinner spinFirst = (Spinner) root.findViewById(R.id.mainPractice_spinIntervalFirst);
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(getActivity(), R.array.time_array,
            android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinFirst.setAdapter(adapter);//from w  ww. jav  a  2s.  c  o  m

    Spinner spinSecond = (Spinner) root.findViewById(R.id.mainPractice_spinIntervalSecond);
    ArrayAdapter<CharSequence> adapter2 = ArrayAdapter.createFromResource(getActivity(), R.array.time_array,
            android.R.layout.simple_spinner_item);
    adapter2.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinSecond.setAdapter(adapter2);

    if (savedInstanceState != null) {
        counting = savedInstanceState.getBoolean(COUNTING);
    }

    return root;
}

From source file:com.cyrilmottier.android.polaris2demo.LayersDemoActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.layers_demo);

    Spinner spinner = (Spinner) findViewById(R.id.layers_spinner);
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.layers_array,
            android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(adapter);// w  w w. ja v  a2 s .co  m
    spinner.setOnItemSelectedListener(this);

    mTrafficCheckbox = (CheckBox) findViewById(R.id.traffic);
    mMyLocationCheckbox = (CheckBox) findViewById(R.id.my_location);

    setUpMapIfNeeded();
}

From source file:com.google.mcommerce.sample.android.chapter09.googleMap.LayersDemoActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.c09_layers_demo);
    mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();

    Spinner spinner = (Spinner) findViewById(R.id.layers_spinner);
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.layers_array,
            android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(adapter);/*from  ww w.j  ava  2 s  .c o  m*/

    spinner.setOnItemSelectedListener(this);
    setUpMapIfNeeded();
}