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.cmput301w15t15.travelclaimsapp.activitys.EditExpenseActivity.java

@Override
protected void onStart() {

    super.onStart();

    if (expense.getName() != null) {
        expenseNameInput.setText(expense.getName());
    } else {/*from ww w .  j ava  2  s  . com*/
        expenseNameInput.setText(expenseName);
    }

    if (expense.getDes() != null) {
        expenseDescriptionInput.setText(expense.getDes().toString());
    }

    if (expense.getCost() != null) {
        expenseCostInput.setText(expense.getCost().toString());
    }
    if (expense.getDate() != null) {
        date.setText(sdf.format(expense.getDate()));
    }

    expenseNameInput.addTextChangedListener(this);

    if (expense.getDate() != null) {
        date.setText(sdf.format(expense.getDate()));
    }

    ArrayAdapter<CharSequence> currencyAdaptor = ArrayAdapter.createFromResource(this, R.array.CurrencyArray,
            R.layout.spinner_item);
    currencyAdaptor.setDropDownViewResource(R.layout.spinner_dropdown_item);
    currencySpinner.setAdapter(currencyAdaptor);

    ArrayAdapter<CharSequence> categoryAdaptor = ArrayAdapter.createFromResource(this, R.array.CategoryArray,
            R.layout.spinner_item);
    categoryAdaptor.setDropDownViewResource(R.layout.spinner_dropdown_item);
    categorySpinner.setAdapter(categoryAdaptor);

    currencySpinner.setSelection(currencyAdaptor.getPosition(expense.getCurr()));
    categorySpinner.setSelection(categoryAdaptor.getPosition(expense.getCat()));

    setEditable();
}

From source file:bbct.android.common.activity.BaseballCardDetails.java

private ArrayAdapter<CharSequence> populateSpinnerAdapter(int arrayId) {
    Activity activity = Objects.requireNonNull(getActivity());
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(activity, arrayId,
            android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

    return adapter;
}

From source file:com.geotrackin.gpslogger.GpsMainActivity.java

public void SetUpActionBar() {
    ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);

    SpinnerAdapter spinnerAdapter = ArrayAdapter.createFromResource(actionBar.getThemedContext(),
            R.array.gps_main_views, android.R.layout.simple_spinner_dropdown_item);

    actionBar.setListNavigationCallbacks(spinnerAdapter, this);

    //Reload the user's previously selected view f73
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    actionBar.setSelectedNavigationItem(prefs.getInt("dropdownview", 0));

    actionBar.setDisplayShowTitleEnabled(true);
    actionBar.setTitle("");
    actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_SHOW_HOME
            | ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_CUSTOM);
    actionBar.setCustomView(R.layout.actionbar);

    ImageButton helpButton = (ImageButton) actionBar.getCustomView().findViewById(R.id.imgHelp);
    helpButton.setOnClickListener(new View.OnClickListener() {
        @Override/*from  ww  w .  ja  va  2s. c  om*/
        public void onClick(View view) {
            Intent faqtivity = new Intent(getApplicationContext(), Faqtivity.class);
            startActivity(faqtivity);
        }
    });

}

From source file:org.travey.travey.QuestionActivity.java

public void prepareQuestions() {
    //add items to spinner
    TextView textView0 = (TextView) findViewById(R.id.textview0);
    TextView textView1 = (TextView) findViewById(R.id.textview1);
    Spinner spinner1 = (Spinner) findViewById(R.id.spinner1);
    spinner1.setOnItemSelectedListener(this);
    TextView textView2 = (TextView) findViewById(R.id.textview2);
    Spinner spinner2 = (Spinner) findViewById(R.id.spinner2);
    spinner2.setOnItemSelectedListener(this);
    TextView textView3 = (TextView) findViewById(R.id.textview3);
    Spinner spinner3 = (Spinner) findViewById(R.id.spinner3);
    spinner3.setOnItemSelectedListener(this);
    TextView textView4 = (TextView) findViewById(R.id.textview4);
    Spinner spinner4 = (Spinner) findViewById(R.id.spinner4);
    spinner4.setOnItemSelectedListener(this);
    TextView textView5 = (TextView) findViewById(R.id.textview5);
    Spinner spinner5 = (Spinner) findViewById(R.id.spinner5);
    spinner5.setOnItemSelectedListener(this);
    TextView textView6 = (TextView) findViewById(R.id.textview6);
    Spinner spinner6 = (Spinner) findViewById(R.id.spinner6);
    spinner6.setOnItemSelectedListener(this);
    TextView textView7 = (TextView) findViewById(R.id.textview7);
    Spinner spinner7 = (Spinner) findViewById(R.id.spinner7);
    spinner7.setOnItemSelectedListener(this);
    TextView textView8 = (TextView) findViewById(R.id.textview8);
    Spinner spinner8 = (Spinner) findViewById(R.id.spinner8);
    spinner8.setOnItemSelectedListener(this);
    Intent i = getIntent();/*from  w  w  w. j  a v  a 2s .  c  o m*/
    String tripText = "This " + metersToPhrase(Integer.parseInt(i.getStringExtra("distance"))) + " trip, took "
            + roundDownTo5(((Long.parseLong(i.getStringExtra("finishTime"))
                    - Long.parseLong(i.getStringExtra("startTime"))) / (1000 * 60) % 60))
            + " minutes, and ended at "
            + dateToQuarters(new Date(Long.parseLong(i.getStringExtra("finishTime")))) + " on "
            + simpleDateFormat.format(new Date(Long.parseLong(i.getStringExtra("finishTime")))) + ".";
    textView0.setText(tripText);
    Log.i("**************", "number of questions:" + NUMBER_QUESTIONS);
    if (NUMBER_QUESTIONS >= 1) { //Q1
        textView1.setText(R.string.survey_question_1);
        ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,
                R.array.survey_question_1_choices, R.layout.my_spinner);
        spinner1.setAdapter(adapter);
    } else {
        textView1.setVisibility(View.GONE);
        ((ViewManager) textView1.getParent()).removeView(textView1);
        spinner1.setVisibility(View.GONE);
        ((ViewManager) spinner1.getParent()).removeView(spinner1);
    }
    if (NUMBER_QUESTIONS >= 2) { //Q2
        textView2.setText(R.string.survey_question_2);
        ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,
                R.array.survey_question_2_choices, R.layout.my_spinner);
        spinner2.setAdapter(adapter);
    } else {
        textView2.setVisibility(View.GONE);
        ((ViewManager) textView2.getParent()).removeView(textView2);
        spinner2.setVisibility(View.GONE);
        ((ViewManager) spinner2.getParent()).removeView(spinner2);
    }
    if (NUMBER_QUESTIONS >= 3) { //Q3
        textView3.setText(R.string.survey_question_3);
        ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,
                R.array.survey_question_3_choices, R.layout.my_spinner);
        spinner3.setAdapter(adapter);
    } else {
        textView3.setVisibility(View.GONE);
        ((ViewManager) textView3.getParent()).removeView(textView3);
        spinner3.setVisibility(View.GONE);
        ((ViewManager) spinner3.getParent()).removeView(spinner3);
    }
    if (NUMBER_QUESTIONS >= 4) { //Q4
        textView4.setText(R.string.survey_question_4);
        ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,
                R.array.survey_question_4_choices, R.layout.my_spinner);
        spinner4.setAdapter(adapter);
    } else {
        textView4.setVisibility(View.GONE);
        ((ViewManager) textView4.getParent()).removeView(textView4);
        spinner4.setVisibility(View.GONE);
        ((ViewManager) spinner4.getParent()).removeView(spinner4);
    }
    if (NUMBER_QUESTIONS >= 5) { //Q5
        textView5.setText(R.string.survey_question_5);
        ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,
                R.array.survey_question_5_choices, R.layout.my_spinner);
        spinner5.setAdapter(adapter);
    } else {
        textView5.setVisibility(View.GONE);
        ((ViewManager) textView5.getParent()).removeView(textView5);
        spinner5.setVisibility(View.GONE);
        ((ViewManager) spinner5.getParent()).removeView(spinner5);
    }
    if (NUMBER_QUESTIONS >= 6) { //Q6
        textView6.setText(R.string.survey_question_6);
        ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,
                R.array.survey_question_6_choices, R.layout.my_spinner);
        spinner6.setAdapter(adapter);
    } else {
        textView6.setVisibility(View.GONE);
        ((ViewManager) textView6.getParent()).removeView(textView6);
        spinner6.setVisibility(View.GONE);
        ((ViewManager) spinner6.getParent()).removeView(spinner6);
    }
    if (NUMBER_QUESTIONS >= 7) { //Q7
        textView7.setText(R.string.survey_question_7);
        ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,
                R.array.survey_question_7_choices, R.layout.my_spinner);
        spinner7.setAdapter(adapter);
    } else {
        textView7.setVisibility(View.GONE);
        ((ViewManager) textView7.getParent()).removeView(textView7);
        spinner7.setVisibility(View.GONE);
        ((ViewManager) spinner7.getParent()).removeView(spinner7);
    }
    if (NUMBER_QUESTIONS >= 8) { //Q8
        textView8.setText(R.string.survey_question_8);
        ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,
                R.array.survey_question_8_choices, R.layout.my_spinner);
        spinner8.setAdapter(adapter);
    } else {
        textView8.setVisibility(View.GONE);
        ((ViewManager) textView8.getParent()).removeView(textView8);
        spinner8.setVisibility(View.GONE);
        ((ViewManager) spinner8.getParent()).removeView(spinner8);
    }
}

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

private void setTextLineExportTargets() {
    ArrayAdapter<CharSequence> shareTargetAdapter = ArrayAdapter.createFromResource(this,
            R.array.sharetexttarget_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_TXTTARGET,
            EXPORT_TYPE_TWITDRIOD);/* w  w w .  j av a 2 s  . com*/
    mShareTargetSpinner.setSelection(lastTarget);

}

From source file:com.example.meetingapp.OptionsFragment.java

private void setupSpinners() {
    mCategoryAdapter = ArrayAdapter.createFromResource(getActivity(), R.array.categories,
            android.R.layout.simple_spinner_item);
    mCategoryAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    mCategorySpinner.setAdapter(mCategoryAdapter);

    ArrayAdapter<CharSequence> minPriceAdapter = ArrayAdapter.createFromResource(getActivity(), R.array.prices,
            android.R.layout.simple_spinner_item);
    minPriceAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    mMinPriceSpinner.setAdapter(minPriceAdapter);

    ArrayAdapter<CharSequence> maxPriceAdapter = ArrayAdapter.createFromResource(getActivity(), R.array.prices,
            android.R.layout.simple_spinner_item);
    maxPriceAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    mMaxPriceSpinner.setAdapter(maxPriceAdapter);

    /* set the default option to be "Very Expensive" */
    mMaxPriceSpinner.setSelection(mPriceOptions.length - 1);
}

From source file:com.f8full.casserolesencours.CasserolesEnCoursActivity.java

/** Called when the activity is first created. */
@Override/*from w  w  w . j a  va2s .c o  m*/
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    Logger.getLogger("com.google.api.client").setLevel(LOGGING_LEVEL);

    //That ease dev of technical stuff BUT is not wanted on a mid/longer term
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

    mTimeFilterSpinner = (Spinner) findViewById(R.id.timeFilterSpinner);
    mTimeFilterAdapter = ArrayAdapter.createFromResource(this, R.array.timeFilter_choices,
            android.R.layout.simple_spinner_item);
    mTimeFilterAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

    mTimeFilterSpinner.setAdapter(mTimeFilterAdapter);

    mDistanceFilterSpinner = (Spinner) findViewById(R.id.distanceFilterSpinner);
    mDistanceFilterAdapter = ArrayAdapter.createFromResource(this, R.array.distanceFilter_choices,
            android.R.layout.simple_spinner_item);
    mDistanceFilterAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

    mDistanceFilterSpinner.setAdapter(mDistanceFilterAdapter);

    mAloharAuthLayout = findViewById(R.id.auth_layout);
    mMainLayout = findViewById(R.id.main_layout);
    mProgress = findViewById(R.id.progress_spin);

    mAccountView = (TextView) findViewById(R.id.account);

    mMainHandler = new Handler();

    mStatusView = (TextView) findViewById(R.id.service_status);
    mServiceToggleButton = (ToggleButton) findViewById(R.id.toggle);
    mUIDView = (EditText) findViewById(R.id.uid);

    mNotificationManager = (NotificationManager) getSystemService(NOTIFIACTION_SERVICE_STRING);

    mAlohar = Alohar.init(getApplication());

    mPlaceManager = mAlohar.getPlaceManager();
    mMotionManager = mAlohar.getMotionManager();

    //mEventManager = EventsManager.getInstance();
    //register listener
    //mPlaceManager.registerPlaceEventListener(mEventManager);
    mMotionManager.registerMotionListener(this);

    //Alohar original, I'm testing the other one
    //mPrefs = PreferenceManager.getDefaultSharedPreferences(this);
    mPrefs = getSharedPreferences(PREF_NAME, MODE_PRIVATE);

    mAloharUid = mPrefs.getString(PREF_KEY, null);
    if (mAloharUid == null) {
        mAlohar.register(APP_ID, API_KEY, this);
    }

    mFusionTableEncID = mPrefs.getString(PREF_TABLE_ENCID, null);

    mRegisterRequestTableID = mPrefs.getString(PREF_REGREQUESTTABLE_ENCID, null);

    if (mRegisterRequestTableID == null) {
        ((Button) findViewById(R.id.refreshRegistration)).setEnabled(false);
    } else {
        ((Button) findViewById(R.id.refreshRegistration)).setEnabled(true);
        ((Button) findViewById(R.id.registerTable)).setEnabled(false);
    }

    mViewOnMasterID = mPrefs.getString(PREF_VIEWONMASTERTABLE_ENCID, null);

    if (mViewOnMasterID == null) {
        ((Button) findViewById(R.id.refreshRegistration)).setEnabled(true);
    } else {
        ((Button) findViewById(R.id.refreshRegistration)).setEnabled(false);
    }

    if (mAlohar.isServiceRunning()) {
        //findViewById(R.id.timeFilterSpinner).setClickable(true);
        mDistanceFilterSpinner.setEnabled(true);
    } else {
        //findViewById(R.id.timeFilterSpinner).setClickable(false);
        mDistanceFilterSpinner.setEnabled(false);
    }

    String tableStatus = mPrefs.getString(PREF_TABLE_STATUS, null);
    if (tableStatus == null) {
        tableStatus = getString(R.string.geolocationStatusRegRequired);
        //Setup interface
        //Done in XML file
    } else {
        //setup interface
        if (tableStatus.equals(getString(R.string.geolocationAnonymizePending))) {
            ((TextView) findViewById(R.id.geolocationStatus))
                    .setTextColor(getResources().getColor(R.color.text_orange));
            ((TextView) findViewById(R.id.geolocationStatus))
                    .setText(getString(R.string.geolocationAnonymizePending));

            ((Button) findViewById(R.id.registerAnonymize)).setVisibility(View.GONE);
            ((Button) findViewById(R.id.checkAnonymize)).setVisibility(View.VISIBLE);
        } else if (tableStatus.equals(getString(R.string.geolocationAnonymizeProcessed))) {
            ((TextView) findViewById(R.id.geolocationStatus))
                    .setTextColor(getResources().getColor(R.color.text_green));
            ((TextView) findViewById(R.id.geolocationStatus))
                    .setText(getString(R.string.geolocationAnonymizeProcessed));

            ((Button) findViewById(R.id.checkAnonymize)).setVisibility(View.GONE);
            ((Button) findViewById(R.id.registerAnonymize)).setVisibility(View.GONE);
            ((Button) findViewById(R.id.logWithGoogle)).setVisibility(View.GONE);
            ((Button) findViewById(R.id.toggleGeolocation)).setVisibility(View.VISIBLE);
            findViewById(R.id.geolocationServiceStatus).setVisibility(View.VISIBLE);
            findViewById(R.id.myDataCheckbox).setEnabled(true);
        } else if (tableStatus.equals(getString(R.string.geolocationStatusRegStart))) {
            findViewById(R.id.logWithGoogle).setVisibility(View.GONE);
            findViewById(R.id.registerAnonymize).setVisibility(View.VISIBLE);
            ((TextView) findViewById(R.id.geolocationStatus))
                    .setTextColor(getResources().getColor(R.color.text_orange));
            ((TextView) findViewById(R.id.geolocationStatus))
                    .setText(getString(R.string.geolocationStatusRegStart));
        }
    }

    ((TextView) findViewById(R.id.tableStatus)).setText(tableStatus);

    if (mAloharUid != null) {
        mUIDView.setText(String.valueOf(mAloharUid));
        onAuthenClick(mUIDView);
    } else {
        mAloharAuthLayout.setVisibility(View.VISIBLE);
    }

    mGOOGCredential = new GoogleCredential.Builder().setTransport(mNetHttpTransport)
            .setJsonFactory(mJaksonJSONFactory)//.build();
            .setClientSecrets(OAuth2ClientCredentials.CLIENT_ID, OAuth2ClientCredentials.CLIENT_SECRET).build();

    mGOOGCredential.setAccessToken(null);
    mGOOGCredential.setRefreshToken(mPrefs.getString(PREF_REFRESH_TOKEN, null));

    //Logger.getLogger("com.google.api.client").setLevel(LOGGING_LEVEL);

    Builder truc = GoogleClient.builder(mNetHttpTransport, mJaksonJSONFactory, new GenericUrl(SERVICE_URL));
    truc.setHttpRequestInitializer(mGOOGCredential);

    mGOOGClient = truc.build();

    mPollFrequencyText = (TextView) findViewById(R.id.pollFrequencyText);
    mPollFrequencyText.setText("N/A when stationary");
    //Something is wrong with the color, I'll see that cosmetic side later
    //mPollFrequencyText.setTextColor(R.color.text_violet);

    mLocationPollThreadExecutor.setKeepAliveTime(0, TimeUnit.SECONDS);

    RadioGroup pollFrequencyRadioGroup = (RadioGroup) findViewById(R.id.pollFrequencyRadioGroup);

    pollFrequencyRadioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(RadioGroup group, int checkedId) {

            cancelActiveTasks();
            startTaskForId(checkedId, true);
        }
    });

    findViewById(R.id.frequency0).setEnabled(false);
    findViewById(R.id.frequency1).setEnabled(false);
    findViewById(R.id.frequency2).setEnabled(false);
    findViewById(R.id.frequency3).setEnabled(false);

}

From source file:org.deviceconnect.android.manager.setting.ReqResDebugActivity.java

/**
 * Spinner??.//from   w ww . j  a  v a2  s.  c  o  m
 */
private void initSpinner() {
    ArrayAdapter<CharSequence> adapterHttpMethod = ArrayAdapter.createFromResource(this, R.array.http_methods,
            android.R.layout.simple_spinner_item);
    adapterHttpMethod.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    ArrayAdapter<CharSequence> adapterProfile = ArrayAdapter.createFromResource(this,
            R.array.dconnect_profile_list, android.R.layout.simple_spinner_item);
    adapterProfile.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.string_empty,
            android.R.layout.simple_spinner_item);
    mHM = (Spinner) findViewById(R.id.reqMethod);
    mHM.setAdapter(adapterHttpMethod);
    mHM.setOnItemSelectedListener(this);
    mProf = (Spinner) findViewById(R.id.reqProfile);
    mProf.setAdapter(adapterProfile);
    mProf.setOnItemSelectedListener(this);
    mInter = (Spinner) findViewById(R.id.reqInterfaces);
    mInter.setOnItemSelectedListener(this);
    mInter.setAdapter(adapter);
    mAttrib = (Spinner) findViewById(R.id.reqAttribute);
    mAttrib.setOnItemSelectedListener(this);
    mAttrib.setAdapter(adapter);
    mDI = (Spinner) findViewById(R.id.reqDeviceid);
    mDI.setOnItemSelectedListener(this);
    mDI.setAdapter(adapter);
}

From source file:com.markupartist.sthlmtraveling.PlannerFragment.java

public void initViews() {
    mSearchView = getActivity().getLayoutInflater().inflate(R.layout.search, null);
    getListView().addHeaderView(mSearchView, null, false);

    final TextView historyView = (TextView) getActivity().getLayoutInflater().inflate(R.layout.header, null);
    historyView.setText(R.string.history_label);
    historyView.setOnClickListener(null); // Makes the header un-clickable, hack!
    getListView().addHeaderView(historyView);

    // Hide dividers on the header view.
    getListView().setHeaderDividersEnabled(false);

    if (!mStartPoint.hasName()) {
        mStartPoint.setName(Site.TYPE_MY_LOCATION);
    }/* www  . j  a v  a 2 s  .c  o m*/
    mStartPointAutoComplete = createAutoCompleteTextView(R.id.from, /*R.id.from_progress*/ -1, mStartPoint);
    mEndPointAutoComplete = createAutoCompleteTextView(R.id.to, /*R.id.to_progress*/ -1, mEndPoint);
    mViaPointAutoComplete = createAutoCompleteTextView(R.id.via, /*R.id.via_progress*/ -1, mViaPoint, true);

    try {
        mHistoryDbAdapter = new HistoryDbAdapter(getActivity()).open();
    } catch (final Exception e) {
        showDialog(createDialogReinstallApp());
        return;
    }

    // Setup view for choosing other data for start and end point.
    final ImageButton fromDialog = (ImageButton) mSearchView.findViewById(R.id.from_menu);
    fromDialog.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(final View v) {
            mStartPointAutoComplete.setError(null);
            showDialog(createDialogStartPoint());
        }
    });
    final ImageButton toDialog = (ImageButton) mSearchView.findViewById(R.id.to_menu);
    toDialog.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(final View v) {
            mEndPointAutoComplete.setError(null);
            showDialog(createDialogEndPoint());
        }
    });
    final ImageButton viaDialog = (ImageButton) mSearchView.findViewById(R.id.via_menu);
    viaDialog.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(final View v) {
            mViaPointAutoComplete.setError(null);
            showDialog(createDialogViaPoint());
        }
    });
    // Views for date and time
    mChangeTimeLayout = (LinearLayout) mSearchView.findViewById(R.id.planner_change_time_layout);

    mDateButton = (Button) mSearchView.findViewById(R.id.planner_route_date);
    mDateButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(final View v) {
            showDialog(createDialogDate());
        }
    });

    mTimeButton = (Button) mSearchView.findViewById(R.id.planner_route_time);
    mTimeButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(final View v) {
            showDialog(createDialogTime());
        }
    });

    // Views for radio buttons
    final RadioButton nowRadioButton = (RadioButton) mSearchView.findViewById(R.id.planner_check_now);
    nowRadioButton.setOnCheckedChangeListener(this);
    final RadioButton laterRadioButton = (RadioButton) mSearchView
            .findViewById(R.id.planner_check_more_choices);
    laterRadioButton.setOnCheckedChangeListener(this);

    mWhenSpinner = (Spinner) mSearchView.findViewById(R.id.departure_arrival_choice);
    final ArrayAdapter<CharSequence> whenChoiceAdapter = ArrayAdapter.createFromResource(getActivity(),
            R.array.when_choice, android.R.layout.simple_spinner_item);
    whenChoiceAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    mWhenSpinner.setAdapter(whenChoiceAdapter);

    // Handle create shortcut.
    if (mCreateShortcut) {
        registerScreen("Planner create shortcut");
        getActivity().setTitle(R.string.create_shortcut_label);

        // Add search label to button

        RadioGroup chooseTimeGroup = (RadioGroup) mSearchView.findViewById(R.id.planner_choose_time_group);
        chooseTimeGroup.setVisibility(View.GONE);
        historyView.setVisibility(View.GONE);
        // Fake an adapter. This needs to be fixed later on so we can use the history.
        setListAdapter(new ArrayAdapter<String>(getActivity(), R.layout.journey_history_row));
    } else {
        setListAdapter(mAdapter);
    }
}

From source file:com.terraremote.terrafieldreport.OpenGroundReport.java

@OnItemSelected(R.id.checkInContactRoleSpinner)
void checkInContactRoleSpinnerSelected(int position) {
    position = mCheckInContactRoleSpinner.getSelectedItemPosition();
    if (position == 0) {
        ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(OpenGroundReport.this,
                R.array.check_in_contact_data_checker_names, android.R.layout.simple_spinner_item);
        // Specify the layout to use when the list of choices appears
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        mCheckInContactNameSpinner.setVisibility(View.VISIBLE);
        mOtherContactName.setVisibility(View.GONE);
        mOtherContactName.setText("");
        // Apply the adapter to the spinner
        mCheckInContactNameSpinner.setAdapter(adapter);
    }//from ww w  . java2  s.c o m
}