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.wncwaterfalls.app.SearchHikeFragment.java

private void setupSpinners(View view) {
    // Trail Length spinner
    trailLengthSpinner = (Spinner) view.findViewById(R.id.search_hike_trail_length_spinner);
    ArrayAdapter<CharSequence> trailLengthAdapter = ArrayAdapter.createFromResource(getActivity(),
            R.array.hike_trail_length_labels, android.R.layout.simple_spinner_item);
    trailLengthAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    trailLengthSpinner.setAdapter(trailLengthAdapter);

    // Trail Difficulty spinner
    trailDifficultySpinner = (Spinner) view.findViewById(R.id.search_hike_trail_difficulty_spinner);
    ArrayAdapter<CharSequence> trailDifficultyAdapter = ArrayAdapter.createFromResource(getActivity(),
            R.array.hike_trail_difficulty_labels, android.R.layout.simple_spinner_item);
    trailDifficultyAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    trailDifficultySpinner.setAdapter(trailDifficultyAdapter);

    // Trail Climb spinner
    trailClimbSpinner = (Spinner) view.findViewById(R.id.search_hike_trail_climb_spinner);
    ArrayAdapter<CharSequence> trailClimbingAdapter = ArrayAdapter.createFromResource(getActivity(),
            R.array.hike_trail_climb_labels, android.R.layout.simple_spinner_item);
    trailClimbingAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    trailClimbSpinner.setAdapter(trailClimbingAdapter);
}

From source file:info.wncwaterfalls.app.SearchLocationFragment.java

private void setupSpinners(View view) {
    locationDistanceSpinner = (Spinner) view.findViewById(R.id.search_location_distance_spinner);
    ArrayAdapter<CharSequence> locationDistanceAdapter = ArrayAdapter.createFromResource(getActivity(),
            R.array.location_distance_labels, android.R.layout.simple_spinner_item);
    locationDistanceAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    locationDistanceSpinner.setAdapter(locationDistanceAdapter);

    locationReltoSpinner = (Spinner) view.findViewById(R.id.search_location_relto_spinner);
    ArrayAdapter<CharSequence> locationReltoAdapter = ArrayAdapter.createFromResource(getActivity(),
            R.array.location_relto_labels, android.R.layout.simple_spinner_item);
    locationReltoAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    locationReltoSpinner.setAdapter(locationReltoAdapter);
    locationReltoSpinner.setOnItemSelectedListener(new SpinnerSelectionListener());
}

From source file:dk.spaceblog.thenicobomb.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mainActivityInstance = this; //Initialize the static instance with the current instance
    // Set the main menu view
    setContentView(R.layout.activity_main);

    // Configure the default values for delay, repeat and intervals.
    delay = interval = repeat = 1;/*from   w  ww  .j a  v  a 2 s.co  m*/
    textMessage = phoneNumber = null;

    // Populate the spinners (http://www.mkyong.com/android/android-spinner-drop-down-list-example/)
    // Repeat spinner
    repeatSpinner = (Spinner) findViewById(R.id.repeatSpinner);
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.sms_repeat_count,
            android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    repeatSpinner.setAdapter(adapter);
    repeatSpinner.setOnItemSelectedListener(new SpinnerOnItemSelectedListener(1));
    repeatSpinner.setSelection(0);

    // Delay spinner
    delaySpinner = (Spinner) findViewById(R.id.delaySpinner);
    ArrayAdapter<CharSequence> adapter2 = ArrayAdapter.createFromResource(this, R.array.sms_delay,
            android.R.layout.simple_spinner_item);
    adapter2.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    delaySpinner.setAdapter(adapter2);
    delaySpinner.setOnItemSelectedListener(new SpinnerOnItemSelectedListener(2));
    delaySpinner.setSelection(0);

    // Interval spinner
    intervalSpinner = (Spinner) findViewById(R.id.intervalSpinner);
    ArrayAdapter<CharSequence> adapter3 = ArrayAdapter.createFromResource(this, R.array.sms_interval,
            android.R.layout.simple_spinner_item);
    adapter3.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    intervalSpinner.setAdapter(adapter3);
    intervalSpinner.setOnItemSelectedListener(new SpinnerOnItemSelectedListener(3));
    intervalSpinner.setSelection(0);

    //Activate the contact button :
    ((ImageButton) findViewById(R.id.pick_contact)).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // user BoD suggests using Intent.ACTION_PICK instead of .ACTION_GET_CONTENT to avoid the chooser
            Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
            // BoD con't: CONTENT_TYPE instead of CONTENT_ITEM_TYPE
            intent.setType(ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE);
            startActivityForResult(intent, 1);
        }
    });

    //Check whether the app has the permission to send SMS :
    this.checkSMSPermission();

}

From source file:edu.berkeley.boinc.attach.AcctMgrFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if (Logging.DEBUG)
        Log.d(Logging.TAG, "AcctMgrFragment onCreateView");
    doBindService();/*from   www  . j  av  a 2  s.  com*/
    View v = inflater.inflate(R.layout.attach_project_acctmgr_dialog, container, false);

    urlSpinner = (Spinner) v.findViewById(R.id.url_spinner);
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(getActivity(),
            R.array.acct_mgr_url_list, android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    urlSpinner.setAdapter(adapter);

    nameInput = (EditText) v.findViewById(R.id.name_input);
    pwdInput = (EditText) v.findViewById(R.id.pwd_input);
    warning = (TextView) v.findViewById(R.id.warning);
    ongoingWrapper = (LinearLayout) v.findViewById(R.id.ongoing_wrapper);
    continueB = (Button) v.findViewById(R.id.continue_button);
    continueB.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View arg0) {
            if (Logging.DEBUG)
                Log.d(Logging.TAG, "AcctMgrFragment continue clicked");
            if (!checkDeviceOnline())
                return;
            if (asIsBound) {

                // get user input
                String url = urlSpinner.getSelectedItem().toString();
                String name = nameInput.getText().toString();
                String pwd = pwdInput.getText().toString();

                // verify input
                int res;
                if ((res = verifyInput(url, name, pwd)) != 0) {
                    warning.setText(res);
                    warning.setVisibility(View.VISIBLE);
                    return;
                }

                // adapt layout
                continueB.setVisibility(View.GONE);
                warning.setVisibility(View.GONE);
                ongoingWrapper.setVisibility(View.VISIBLE);

                String[] params = new String[3];
                params[0] = url;
                params[1] = name;
                params[2] = pwd;
                asyncTask = new AttachProjectAsyncTask();
                asyncTask.execute(params);

            } else if (Logging.DEBUG)
                Log.d(Logging.TAG, "AcctMgrFragment service not bound, do nothing...");
        }
    });

    return v;
}

From source file:com.dgsd.android.ShiftTracker.MainActivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    final ActionBar ab = getSupportActionBar();

    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.nav_items,
            R.layout.sherlock_spinner_item);
    adapter.setDropDownViewResource(R.layout.sherlock_spinner_dropdown_item);

    ab.setDisplayShowTitleEnabled(false);
    ab.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
    ab.setListNavigationCallbacks(adapter, this);

    mPrefs = Prefs.getInstance(this);

    //Show our 'Rate in Market' dialog if needed
    AppRating.app_launched(this);

    final int currentJd = TimeUtils.getCurrentJulianDay();
    mWeekPagerAdapter = new WeekPagerAdapter(this, getSupportFragmentManager(), currentJd);
    mMonthPagerAdapter = new MonthPagerAdapter(this, getSupportFragmentManager(), currentJd);

    mPager = (ViewPager) findViewById(R.id.pager);
    mPager.setAdapter(mWeekPagerAdapter);
    mPager.setOffscreenPageLimit(1);/*from  w  w  w.j a  v a 2  s  .  co m*/

    if (Api.isMin(Api.HONEYCOMB) && !StApp.isFreeApp(this)) {
        final int animType = Integer.valueOf(mPrefs.get(getString(R.string.settings_key_animation), "0"));

        ViewPager.PageTransformer transformer = null;
        switch (animType) {
        case ANIM_TYPE_INNER_CUBE:
            transformer = PageTransformerUtils.getInnerCubeTransformer();
            break;
        case ANIM_TYPE_OUTER_CUBE:
            transformer = PageTransformerUtils.getOuterCubeTransformer();
            break;
        case ANIM_TYPE_TWIST:
            transformer = PageTransformerUtils.getTwistTransformer();
            break;
        case ANIM_TYPE_COMPRESS:
            transformer = PageTransformerUtils.getCompressTransformer();
            break;
        }

        if (transformer != null)
            mPager.setPageTransformer(false, transformer);
    }

    mIndicator = (TitlePageIndicator) findViewById(R.id.indicator);
    mIndicator.setViewPager(mPager, mWeekPagerAdapter.getPositionForJulianDay(currentJd));

    ab.setSelectedNavigationItem(mPrefs.get(KEY_SELECTED_INDEX, 0));
}

From source file:edu.asu.msse.sgowdru.moviesqldb.SearchMovie.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.search_movie);
    info = new TextView[5];
    //In the info array of TextView type store id of each field
    info[0] = (TextView) findViewById(R.id.autoCompleteTextView);
    info[1] = (TextView) findViewById(R.id.editTitleSearch);
    info[2] = (TextView) findViewById(R.id.editGenreSearch);
    info[3] = (TextView) findViewById(R.id.editYearSearch);
    info[4] = (TextView) findViewById(R.id.editActorsSearch);

    //Ratings field is of type Spinner class with field values (PG, PG-13, R rated)
    dropdown = (Spinner) findViewById(R.id.spinnerSearch);
    adapter = ArrayAdapter.createFromResource(this, R.array.Ratings, android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    dropdown.setAdapter(adapter);/*from   w w w. j a v a 2 s . co m*/

    btn = (Button) findViewById(R.id.addSearch);

    context = getApplicationContext();
    duration = Toast.LENGTH_LONG;

    db = new MoviesDB(this);
    try {
        crsDB = db.openDB();
    } catch (SQLException e) {
        e.printStackTrace();
    }

    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line,
            gen);
    AutoCompleteTextView textView = (AutoCompleteTextView) findViewById(R.id.editGenreSearch);
    textView.setAdapter(adapter);
}

From source file:com.enadein.carlogbook.CarLogbook.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    menuList = (ListView) findViewById(R.id.menu);
    drawer = (DrawerLayout) findViewById(R.id.drawer_layout);

    if (savedInstanceState != null) {
        rotate = savedInstanceState.getBoolean(ROTATE);
    }/*from   w w w. ja  va2  s .c om*/

    MenuAdapter menuAdapter = new MenuAdapter(this, 0, buildMenu());
    menuList.setAdapter(menuAdapter);
    menuList.setOnItemClickListener(new DrawerItemClickListener());
    initDrawer();

    if (!rotate) {
        mediator.showLogbook();
    }

    ArrayAdapter reportItemsAdapter = ArrayAdapter.createFromResource(CarLogbook.this, R.array.action_list,
            android.R.layout.simple_spinner_item);
    reportItemsAdapter.setDropDownViewResource(R.layout.simple_spinner_dropdown_item);

    rotate = false;

    //TODO
    initInAppBuilingV3();
}

From source file:com.cse3310.phms.ui.activities.AddAppointmentActivity.java

@AfterViews
void onSetupViews() {
    if (mSelectedDate != null) {
        appointmentTime = mSelectedDate.getTime();
    }//from   w  w  w  .j a v  a 2  s  .  co  m

    // set spinner to get early reminder time
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.early_reminder_chose,
            android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    mReminderSpinner.setAdapter(adapter);
    mReminderSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            switch (position) {
            case 0:
                earlyMillis = 0;
                break;
            case 1:
                earlyMillis = TimeUnit.MINUTES.toMillis(5);
                break;
            case 2:
                earlyMillis = TimeUnit.MINUTES.toMillis(10);
                break;
            case 3:
                earlyMillis = TimeUnit.MINUTES.toMillis(30);
                break;
            case 4:
                earlyMillis = TimeUnit.HOURS.toMillis(1);
                break;
            case 5:
                earlyMillis = TimeUnit.HOURS.toMillis(2);
                break;
            case 6:
                earlyMillis = TimeUnit.HOURS.toMillis(12);
                break;
            case 7:
                earlyMillis = TimeUnit.HOURS.toMillis(24);
                break;
            case 8:
                earlyMillis = TimeUnit.DAYS.toMillis(2);
                break;
            case 9:
                earlyMillis = TimeUnit.DAYS.toMillis(7);
                break;
            }
        }

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

        }
    });

    mAppointmentView.setVisibility(View.GONE);
    mTimeButtonTextView.setText(MyDateFormatter.formatTime(mSelectedDate.getTime()));
}

From source file:com.willowtreeapps.spurceexampleapp.SpruceActivity.java

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.fragment_pager);

    FragmentManager fm = getSupportFragmentManager();

    VerticalViewPager verticalPager = (VerticalViewPager) findViewById(R.id.vertical_pager);
    VerticalPagerAdapter adapter = new VerticalPagerAdapter(fm);
    verticalPager.setAdapter(adapter);/*from ww  w  .  ja v  a  2  s  . com*/

    Toolbar toolBar = (Toolbar) findViewById(R.id.tool_bar);
    setSupportActionBar(toolBar);
    if (getSupportActionBar() != null) {
        getSupportActionBar().setDisplayShowTitleEnabled(false);
    }

    sortDropDown = (Spinner) findViewById(R.id.sort_selection);
    ArrayAdapter<CharSequence> spinnerAdapter = ArrayAdapter.createFromResource(this, R.array.sort_functions,
            R.layout.spinner_item);
    spinnerAdapter.setDropDownViewResource(R.layout.support_simple_spinner_dropdown_item);
    sortDropDown.setAdapter(spinnerAdapter);
}

From source file:com.rappsantiago.weighttracker.profile.setup.WeightHeightFragment.java

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

    mTxtWeightWrapper = (TextInputLayout) view.findViewById(R.id.txt_weight_wrapper);
    mTxtBodyFatIndexWrapper = (TextInputLayout) view.findViewById(R.id.txt_bfi_wrapper);
    mTxtHeightWrapper = (TextInputLayout) view.findViewById(R.id.txt_height_wrapper);
    mTxtHeightInchesWrapper = (TextInputLayout) view.findViewById(R.id.txt_height_inches_wrapper);

    Spinner weightUnitDropdown = (Spinner) view.findViewById(R.id.dropdown_weight_unit);
    mWeightUnitAdapter = ArrayAdapter.createFromResource(getContext(), R.array.arr_weight_unit,
            android.R.layout.simple_spinner_item);
    weightUnitDropdown.setAdapter(mWeightUnitAdapter);
    weightUnitDropdown.setOnItemSelectedListener(this);

    Spinner heightUnitDropdown = (Spinner) view.findViewById(R.id.dropdown_height_unit);
    mHeightUnitAdapter = ArrayAdapter.createFromResource(getContext(), R.array.arr_height_unit,
            android.R.layout.simple_spinner_item);
    heightUnitDropdown.setAdapter(mHeightUnitAdapter);
    heightUnitDropdown.setOnItemSelectedListener(this);

    return view;/*  w w  w.jav  a 2s  . c  o m*/
}