Example usage for android.widget ArrayAdapter setDropDownViewResource

List of usage examples for android.widget ArrayAdapter setDropDownViewResource

Introduction

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

Prototype

public void setDropDownViewResource(@LayoutRes int resource) 

Source Link

Document

Sets the layout resource to create the drop down views.

Usage

From source file:com.dmsl.anyplace.SelectBuildingActivity.java

private void setFloorSpinner(List<FloorModel> floors) {

    List<String> list = new ArrayList<String>();
    for (FloorModel floor : floors) {
        list.add(floor.toString());/*  w w  w  . j ava  2  s. c om*/
    }

    ArrayAdapter<String> spinnerFloorsAdapter;
    spinnerFloorsAdapter = new ArrayAdapter<String>(getBaseContext(), android.R.layout.simple_spinner_item,
            list);
    spinnerFloorsAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinnerFloors.setAdapter(spinnerFloorsAdapter);
}

From source file:com.example.android.wearable.wear.wearnotifications.StandaloneMainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Log.d(TAG, "onCreate()");

    setContentView(R.layout.activity_main);
    setAmbientEnabled();//from ww  w .j a  va 2  s  .c o  m

    mMainRelativeLayout = (RelativeLayout) findViewById(R.id.mainRelativeLayout);
    mSpinner = (Spinner) findViewById(R.id.spinner);

    mNotificationManagerCompat = NotificationManagerCompat.from(getApplicationContext());

    // Create an ArrayAdapter using the string array and a default spinner layout
    ArrayAdapter<CharSequence> adapter = new ArrayAdapter(this, android.R.layout.simple_spinner_item,
            NOTIFICATION_STYLES);
    // Specify the layout to use when the list of choices appears
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    // Apply the adapter to the spinner
    mSpinner.setAdapter(adapter);
    mSpinner.setOnItemSelectedListener(this);

}

From source file:com.mifos.mifosxdroid.online.grouploanaccount.GroupLoanAccountFragment.java

@Override
public void showLoanPurposeSpinner(ResponseBody result) {

    mResponse = result;/*from  ww w .ja  v a  2 s .  c om*/

    inflateFrequencyPeriodSpinner(mResponse);
    inflateAmortizationSpinner(mResponse);
    inflateInterestCalculationPeriodSpinner(mResponse);
    //inflaterepaymentFrequencyTypeOptionsSpinner();
    inflatetransactionProcessingStrategySpinner(mResponse);

    final List<LoanPurposeOptions> loanPurposeOptionsType = new ArrayList<>();
    // you can use this array to populate your spinner
    final ArrayList<String> loanPurposeOptionsTypeNames = new ArrayList<String>();
    //Try to get response body
    BufferedReader reader = null;
    StringBuilder sb = new StringBuilder();
    try {
        reader = new BufferedReader(new InputStreamReader(result.byteStream()));
        String line;
        while ((line = reader.readLine()) != null) {
            sb.append(line);
        }
        JSONObject obj = new JSONObject(sb.toString());
        if (obj.has("loanPurposeOptions")) {
            JSONArray loanPurposeOptionsTypes = obj.getJSONArray("loanPurposeOptions");
            for (int i = 0; i < loanPurposeOptionsTypes.length(); i++) {
                JSONObject loanPurposeOptionsTypesObject = loanPurposeOptionsTypes.getJSONObject(i);
                LoanPurposeOptions loanpurpose = new LoanPurposeOptions();
                loanpurpose.setId(loanPurposeOptionsTypesObject.optInt("id"));
                loanpurpose.setName(loanPurposeOptionsTypesObject.optString("name"));
                loanPurposeOptionsType.add(loanpurpose);
                loanPurposeOptionsTypeNames.add(loanPurposeOptionsTypesObject.optString("name"));
                loanPurposeNameIdHashMap.put(loanpurpose.getName(), loanpurpose.getId());
            }

        }
        String stringResult = sb.toString();
    } catch (Exception e) {
        Log.e(LOG_TAG, "", e);
    }
    final ArrayAdapter<String> loanPTypeAdapter = new ArrayAdapter<>(getActivity(), layout.simple_spinner_item,
            loanPurposeOptionsTypeNames);

    loanPTypeAdapter.setDropDownViewResource(layout.simple_spinner_dropdown_item);
    sp_loan_purpose.setAdapter(loanPTypeAdapter);
    sp_loan_purpose.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
            loanPurposeId = loanPurposeNameIdHashMap.get(loanPurposeOptionsTypeNames.get(i));
            Log.d("loanpurpose" + loanPurposeOptionsTypeNames.get(i), String.valueOf(loanPurposeId));
            if (loanPurposeId != -1) {

            } else {

                Toast.makeText(getActivity(), getString(R.string.error_select_fund), Toast.LENGTH_SHORT).show();

            }

        }

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

        }
    });
}

From source file:com.wishlist.Wishlist.java

/** Called when the activity is first created. */
@Override//from   w  w  w . jav  a2s . c  om
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (APP_ID == null) {
        Util.showAlert(this, "Warning",
                "Facebook Applicaton ID must be " + "specified before running this example: see FbAPIs.java");
        return;
    }

    setContentView(R.layout.wishlist);
    mHandler = new Handler();

    mText = (TextView) Wishlist.this.findViewById(R.id.txt);
    mUserPic = (ImageView) Wishlist.this.findViewById(R.id.user_pic);
    mProduceName = (EditText) Wishlist.this.findViewById(R.id.product_name);

    mWishlistSpinner = (Spinner) Wishlist.this.findViewById(R.id.wishlist_spinner);
    mPlacesListSpinner = (Spinner) Wishlist.this.findViewById(R.id.location);

    image = (ImageView) Wishlist.this.findViewById(R.id.itemPhoto);

    image.setImageResource(R.drawable.camera);
    image.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(Intent.ACTION_PICK, (MediaStore.Images.Media.EXTERNAL_CONTENT_URI));
            startActivityForResult(intent, PICK_EXISTING_PHOTO_RESULT_CODE);
        }
    });

    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.wishlist_array,
            android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    mWishlistSpinner.setAdapter(adapter);

    mPlacesListSpinner.setClickable(false);

    mAddtoTimeline = (Button) Wishlist.this.findViewById(R.id.timeline);
    mAddtoTimeline.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (!Utility.mFacebook.isSessionValid()) {
                showToast(getString(R.string.must_login));
                return;
            }
            mProductName = mProduceName.getText().toString();
            if (mProductName == null || TextUtils.isEmpty(mProductName)) {
                showToast(getString(R.string.enter_product_name));
                return;
            }
            if (imageBytes == null) {
                showToast(getString(R.string.take_product_photo));
                return;
            }
            /*
             * Upload photo first and then publish to the timeline after successful photo upload.
             */
            uploadPhoto();
        }
    });
    /*
     * Initalize Facebook Object, retrieve access token and layout the Login button
     */
    initFacebook();
}

From source file:com.zira.registration.VehicleInformationActivity.java

protected void setApapterForVehicleYear(String year) {

    int yearIntValue;

    try {/*from   www .ja va2 s .c o  m*/
        yearIntValue = Integer.parseInt(year);
    } catch (Exception e) {
        yearIntValue = 0;
    }

    ArrayList<String> years = new ArrayList<String>();
    years.add("Choose Vehicle Year");

    if (yearIntValue > 0) {
        for (int i = yearIntValue; i <= Calendar.getInstance().get(Calendar.YEAR); i++) {
            years.add(String.valueOf(i));
        }
    }

    /******************************/

    if (years.size() > 0) {
        String gettingVehicleYear = mProfileInfoModel.getVechile_year();
        //            if(gettingVehicleYear.equals(""))
        //            {
        //               gettingVehicleYear=prefs3.getString("year", "");
        //            }
        int i = 0;
        for (String s : years) {
            String vehicleyear = s;
            if (gettingVehicleYear.equals(vehicleyear)) {
                gettingVehicleYearPosition = i;
            }
            i++;
        }
    }
    /******************************/

    ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this, R.layout.spinner_list, years);
    dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    vehiclemodalYearSpinner.setAdapter(dataAdapter);
    if (value == 1)
        if (vehicle_flag > 1) {
            vehiclemodalYearSpinner.setSelection(0);
        } else {
            if (years.size() > gettingVehicleYearPosition) {
                vehiclemodalYearSpinner.setSelection(gettingVehicleYearPosition);
            }

        }
}

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);
    }/* ww  w.j  a va2 s  .  com*/

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

From source file:com.example.android.cupboard.EditorActivity.java

/**
 * Setup the dropdown spinner that allows the user to select the units for the amount of food.
 *//*www .j a v a  2  s. com*/
private void setupSpinner() {
    // Create adapter for spinner. The list options are from the String array it will use
    // the spinner will use the default layout
    ArrayAdapter unitsSpinnerAdapter = ArrayAdapter.createFromResource(this, R.array.array_units_options,
            android.R.layout.simple_spinner_item);

    // Specify dropdown layout style - simple list view with 1 item per line
    unitsSpinnerAdapter.setDropDownViewResource(android.R.layout.simple_dropdown_item_1line);

    // Apply the adapter to the spinner
    mUnitsSpinner.setAdapter(unitsSpinnerAdapter);

    // Set the integer mSelected to the constant values
    mUnitsSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            String selection = (String) parent.getItemAtPosition(position);
            if (!TextUtils.isEmpty(selection)) {
                if (selection.equals(getString(R.string.units_g))) {
                    mUnit = FoodEntry.UNITS_G;
                } else if (selection.equals(getString(R.string.units_kg))) {
                    mUnit = FoodEntry.UNITS_KG;
                } else if (selection.equals(getString(R.string.units_ml))) {
                    mUnit = FoodEntry.UNITS_ML;
                } else if (selection.equals(getString(R.string.units_l))) {
                    mUnit = FoodEntry.UNITS_L;
                } else {
                    mUnit = FoodEntry.UNITS_UNKNOWN;
                }
            }
        }

        // Because AdapterView is an abstract class, onNothingSelected must be defined
        @Override
        public void onNothingSelected(AdapterView<?> parent) {
            mUnit = FoodEntry.UNITS_UNKNOWN;
        }
    });
}

From source file:de.uni_koblenz_landau.apow.PatientDetailEditFragment.java

/**
 * Called by EncounterDetailTask, when loading is finished.
 *//*from   w w w  .  j  a va2s  .c  o m*/
@Override
public void onPatientFetched(Patient patient, List<Region> regions) {
    mPatientDetailTask = null;

    // If result is not empty, update UI, else show error message.
    if (regions != null) {
        mRegions = regions;
        ArrayAdapter<Region> adapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_spinner_item,
                regions);
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        mRegionsView.setAdapter(adapter);
        ArrayAdapter<District> adapter1 = new ArrayAdapter<>(getActivity(),
                android.R.layout.simple_spinner_item, regions.get(0).getDistricts());
        adapter1.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        mDistrictsView.setAdapter(adapter1);

        if (patient != null) {
            mPatient = patient;
            if (mPatient.getPatientIdentifier() != null) {
                Helper.setViewText(mIdentifierView, mPatient.getPatientIdentifier().getIdentifier());
            }

            if (mPatient.getPersonName() != null) {
                getActivity().setTitle(mPatient.getPersonName().getFullName());
                Helper.setViewText(mNamePrefixView, mPatient.getPersonName().getPrefix());
                Helper.setViewText(mGivenNameView, mPatient.getPersonName().getGivenName());
                Helper.setViewText(mMiddleNameView, mPatient.getPersonName().getMiddleName());
                Helper.setViewText(mFamilyNamePrefixView, mPatient.getPersonName().getFamilyNamePrefix());
                Helper.setViewText(mFamilyNameView, mPatient.getPersonName().getFamilyName());
                Helper.setViewText(mFamilyName2View, mPatient.getPersonName().getFamilyName2());
                Helper.setViewText(mFamilyNameSuffixView, mPatient.getPersonName().getFamilyNameSuffix());
                Helper.setViewText(mDegreeView, mPatient.getPersonName().getDegree());
            }

            if (mPatient.getGender() != null) {
                switch (mPatient.getGender()) {
                case "U":
                    mGenderView.setSelection(0);
                    break;
                case "F":
                    mGenderView.setSelection(1);
                    break;
                case "M":
                    mGenderView.setSelection(2);
                    break;
                }
            } else {
                mGenderView.setSelection(0);
            }
            if (mPatient.getBirthdate() != null) {
                Helper.setViewText(mBirthdateView,
                        Helper.dateToLocaleString(mPatient.getBirthdate(), getActivity()));
            }
            mBirthdateEstimatedView.setChecked(mPatient.isBirthdateEstimated());
            if (mPatient.getPersonAddress() != null) {
                Helper.setViewText(mAddress1View, mPatient.getPersonAddress().getAddress1());
                Helper.setViewText(mAddress2View, mPatient.getPersonAddress().getAddress2());
                Helper.setViewText(mCityVillageView, mPatient.getPersonAddress().getCityVillage());

                String selectedRegion = mPatient.getPersonAddress().getStateProvince();
                String selectedDistrict = mPatient.getPersonAddress().getCountyDistrict();
                for (int i = 0; i < adapter.getCount(); i++) {
                    Region region = adapter.getItem(i);
                    if (region.getRegionName().equals(selectedRegion)) {
                        for (int j = 0; j < region.getDistricts().size(); j++) {
                            if (region.getDistricts().get(j).getDistrictName().equals(selectedDistrict)) {
                                mRegionsView.setTag(j);
                                mRegionsView.setSelection(i, false);
                                adapter1 = new ArrayAdapter<>(getActivity(),
                                        android.R.layout.simple_spinner_item, region.getDistricts());
                                adapter1.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
                                mDistrictsView.setAdapter(adapter1);
                                mDistrictsView.setSelection(j, false);
                                break;
                            }
                        }
                        break;
                    }
                }
                Helper.setViewText(mCountryView, mPatient.getPersonAddress().getCountry());
                Helper.setViewText(mLongitudeView, mPatient.getPersonAddress().getLongitude());
                Helper.setViewText(mLatitudeView, mPatient.getPersonAddress().getLatitude());
            }

            mDeadView.setChecked(mPatient.getDead());
            if (mPatient.getDead()) {
                if (mPatient.getDeathDate() != null) {
                    Helper.setViewText(mDeathdateView,
                            Helper.dateToLocaleString(mPatient.getDeathDate(), getActivity()));
                }
                mDeadLayout.setVisibility(View.VISIBLE);
            } else {
                mDeadLayout.setVisibility(View.GONE);
            }
        } else {
            mPatient = new Patient();
            PatientIdentifier patientIdentifier = new PatientIdentifier();
            PatientIdentifierType patientIdentifierType = new PatientIdentifierType();
            patientIdentifierType.setName(Constants.IDENTIFIER_TYPE_NAME);
            patientIdentifier.setIdentifierType(patientIdentifierType);
            mPatient.addIdentifier(patientIdentifier);
            PersonName personName = new PersonName();
            mPatient.addName(personName);
            PersonAddress personAddress = new PersonAddress();
            mPatient.addAddress(personAddress);
        }
    } else {
        Toast.makeText(getActivity(), R.string.error_database, Toast.LENGTH_SHORT).show();
    }
}

From source file:biz.incomsystems.fwknop2.ConfigDetailFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_config_detail, container, false);
    active_Nick = getArguments().getString("item_id");
    myJuice = new PluginContract();

    //Handlers for the input fields
    txt_NickName = (TextView) rootView.findViewById(R.id.NickName);
    txt_allowIP = (TextView) rootView.findViewById(R.id.iptoallow);
    lay_allowIP = (LinearLayout) rootView.findViewById(R.id.iptoallowsl);
    lay_natIP = (LinearLayout) rootView.findViewById(R.id.natipsl);
    lay_natport = (LinearLayout) rootView.findViewById(R.id.natportsl);
    lay_serverCMD = (LinearLayout) rootView.findViewById(R.id.servercmdsl);
    txt_ports = (TextView) rootView.findViewById(R.id.AccessPorts);
    txt_server_ip = (TextView) rootView.findViewById(R.id.destIP);
    txt_server_port = (TextView) rootView.findViewById(R.id.destPort);
    txt_server_time = (TextView) rootView.findViewById(R.id.fwTimeout);
    txt_server_cmd = (TextView) rootView.findViewById(R.id.servercmd);
    txt_nat_ip = (TextView) rootView.findViewById(R.id.natip);
    txt_nat_port = (TextView) rootView.findViewById(R.id.natport);
    lay_AccessPort = (LinearLayout) rootView.findViewById(R.id.AccessPortsl);
    lay_fwTimeout = (LinearLayout) rootView.findViewById(R.id.fwTimeoutl);
    lay_sshcmd = (LinearLayout) rootView.findViewById(R.id.sshcmdsl);
    txt_ssh_cmd = (TextView) rootView.findViewById(R.id.sshcmd);
    txt_KEY = (TextView) rootView.findViewById(R.id.passwd);
    txt_HMAC = (TextView) rootView.findViewById(R.id.hmac);
    chkb64hmac = (CheckBox) rootView.findViewById(R.id.chkb64hmac);
    chkb64key = (CheckBox) rootView.findViewById(R.id.chkb64key);

    spn_juice = (Spinner) rootView.findViewById(R.id.juice_spn);
    juice_adapt = new ConnectionSpinnerAdapter(getActivity());
    spn_juice.setAdapter(juice_adapt);//  ww  w . jav a 2 s  . com

    spn_allowip = (Spinner) rootView.findViewById(R.id.allowip);
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(getActivity(), R.array.spinner_options,
            android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spn_allowip.setAdapter(adapter);
    spn_allowip.setOnItemSelectedListener(new OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
            if (parent.getItemAtPosition(pos).toString().equalsIgnoreCase("Allow IP")) {
                lay_allowIP.setVisibility(View.VISIBLE);
            } else {
                lay_allowIP.setVisibility(View.GONE);
            }
        }

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

    spn_ssh = (Spinner) rootView.findViewById(R.id.ssh);
    ArrayAdapter<CharSequence> adapter_ssh = ArrayAdapter.createFromResource(getActivity(), R.array.ssh_options,
            android.R.layout.simple_spinner_item);
    adapter_ssh.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spn_ssh.setAdapter(adapter_ssh);
    spn_ssh.setOnItemSelectedListener(new OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
            // An item was selected. You can retrieve the selected item using
            // parent.getItemAtPosition(pos)
            if (parent.getItemAtPosition(pos).toString().equalsIgnoreCase("None")) {
                lay_sshcmd.setVisibility(View.GONE);
                spn_juice.setVisibility(View.GONE);
                // blank the other options here
            } else if (parent.getItemAtPosition(pos).toString().equalsIgnoreCase("SSH Uri")) {
                // show the txt for the uri
                lay_sshcmd.setVisibility(View.VISIBLE);
                spn_juice.setVisibility(View.GONE);
            } else if (parent.getItemAtPosition(pos).toString().equalsIgnoreCase("Juicessh")) {
                lay_sshcmd.setVisibility(View.GONE);

                if (connectionListLoader == null) {
                    connectionListLoader = new ConnectionListLoader(getActivity(), juice_adapt);
                    connectionListLoader.setOnLoadedListener(new ConnectionListLoader.OnLoadedListener() {
                        @Override
                        public void onLoaded() { // This is so ugly...
                            spn_juice.setVisibility(View.VISIBLE);
                            if (config.SSH_CMD.contains("juice:") && spn_juice.getCount() > 0) {
                                for (int n = 0; n < spn_juice.getCount(); n++) {
                                    if (config.SSH_CMD.contains(juice_adapt.getConnectionName(n))) {
                                        spn_juice.setSelection(n);
                                    }
                                }
                            }
                        }
                    });
                    getActivity().getSupportLoaderManager().initLoader(0, null, connectionListLoader);
                } else {
                    getActivity().getSupportLoaderManager().restartLoader(0, null, connectionListLoader);
                }
            }
        }

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

    spn_configtype = (Spinner) rootView.findViewById(R.id.configtype);
    ArrayAdapter<CharSequence> adapter2 = ArrayAdapter.createFromResource(getActivity(),
            R.array.configtype_options, android.R.layout.simple_spinner_item);
    adapter2.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spn_configtype.setAdapter(adapter2);
    spn_configtype.setOnItemSelectedListener(new OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
            if (parent.getItemAtPosition(pos).toString().equalsIgnoreCase("Open Port")) {
                configtype = "Open Port";
                lay_AccessPort.setVisibility(View.VISIBLE);
                lay_fwTimeout.setVisibility(View.VISIBLE);
                txt_nat_ip.setText("");
                txt_nat_port.setText("");
                txt_server_cmd.setText("");
            } else {
                lay_AccessPort.setVisibility(View.GONE);
                lay_fwTimeout.setVisibility(View.GONE);
            }
            if (parent.getItemAtPosition(pos).toString().equalsIgnoreCase("Nat Access")) {
                configtype = "Nat Access";
                txt_server_cmd.setText("");
                lay_AccessPort.setVisibility(View.VISIBLE);
                lay_fwTimeout.setVisibility(View.VISIBLE);
                lay_natIP.setVisibility(View.VISIBLE);
                lay_natport.setVisibility(View.VISIBLE);
            } else {
                lay_natIP.setVisibility(View.GONE);
                lay_natport.setVisibility(View.GONE);
            }
            if (parent.getItemAtPosition(pos).toString().equalsIgnoreCase("Server Command")) {
                configtype = "Server Command";
                lay_serverCMD.setVisibility(View.VISIBLE);
                txt_ports.setText("");
                txt_nat_ip.setText("");
                txt_nat_port.setText("");
                txt_server_time.setText("");
            } else {
                lay_serverCMD.setVisibility(View.GONE);
            }
        }

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

    //Below is the loading of a saved config
    if (active_Nick.equalsIgnoreCase("")) {
        txt_NickName.setText("");
        config.SSH_CMD = "";
        txt_HMAC.setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
        txt_KEY.setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
    } else {
        config = mydb.getConfig(active_Nick);
        txt_NickName.setText(active_Nick);
        if (config.ACCESS_IP.equalsIgnoreCase("Resolve IP")) {
            spn_allowip.setSelection(0);
        } else if (config.ACCESS_IP.equalsIgnoreCase("0.0.0.0")) {
            spn_allowip.setSelection(1);
        } else {
            spn_allowip.setSelection(2);
            txt_allowIP.setText(config.ACCESS_IP);
        }
        txt_ports.setText(config.PORTS);
        txt_server_ip.setText(config.SERVER_IP);
        txt_server_port.setText(config.SERVER_PORT);
        txt_server_time.setText(config.SERVER_TIMEOUT);
        txt_KEY.setText(config.KEY);
        if (config.KEY_BASE64) {
            chkb64key.setChecked(true);
        } else {
            chkb64key.setChecked(false);
        }
        txt_HMAC.setText(config.HMAC);
        if (config.HMAC_BASE64) {
            chkb64hmac.setChecked(true);
        } else {
            chkb64hmac.setChecked(false);
        }
        if (!config.SERVER_CMD.equalsIgnoreCase("")) {
            spn_configtype.setSelection(2);
            txt_server_cmd.setText(config.SERVER_CMD);
        } else if (!config.NAT_IP.equalsIgnoreCase("")) {
            spn_configtype.setSelection(1);
            txt_ports.setText(config.PORTS);
            txt_nat_ip.setText(config.NAT_IP);
            txt_nat_port.setText(config.NAT_PORT);
            txt_server_time.setText(config.SERVER_TIMEOUT);
        } else {
            spn_configtype.setSelection(0);
        }
        if (config.SSH_CMD.equalsIgnoreCase("")) {
            spn_ssh.setSelection(0);
        } else if (config.SSH_CMD.contains("juice:")) {
            spn_ssh.setSelection(2);
        } else {
            spn_ssh.setSelection(1);
            txt_ssh_cmd.setText(config.SSH_CMD);
        }
    }
    return rootView;
}

From source file:com.binomed.showtime.android.screen.search.CineShowTimeSearchFragment.java

private void initViewsState() {

    fillAutoField();/* w  w w  .j  a  va  2 s  .c  o  m*/
    ArrayAdapter<String> adapterSpinner = new ArrayAdapter<String>(fragmentInteraction.getMainContext() //
            , R.layout.view_spinner_item//
            , CineShowtimeDateNumberUtil.getSpinnerDaysValues(fragmentInteraction.getMainContext())//
    );
    adapterSpinner.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinnerChooseDay.setAdapter(adapterSpinner);

}