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:eu.power_switch.api.taskerplugin.EditActivity.java

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

    View.OnClickListener actionTypeOnClickListener = new View.OnClickListener() {
        @Override//w  w  w .  j  a va2 s.  c o  m
        public void onClick(View v) {
            if (v.getId() == R.id.radioButton_receiver_action) {
                updateActionType(Action.ACTION_TYPE_RECEIVER);
            } else if (v.getId() == R.id.radioButton_room_action) {
                updateActionType(Action.ACTION_TYPE_ROOM);
            } else if (v.getId() == R.id.radioButton_scene_action) {
                updateActionType(Action.ACTION_TYPE_SCENE);
            }

            updateLists();
            setPositiveButtonVisibility(checkValidity());
        }
    };

    // Action Type Selection
    radioButtonReceiverAction = (RadioButton) findViewById(R.id.radioButton_receiver_action);
    radioButtonReceiverAction.setOnClickListener(actionTypeOnClickListener);
    radioButtonRoomAction = (RadioButton) findViewById(R.id.radioButton_room_action);
    radioButtonRoomAction.setOnClickListener(actionTypeOnClickListener);
    radioButtonSceneAction = (RadioButton) findViewById(R.id.radioButton_scene_action);
    radioButtonSceneAction.setOnClickListener(actionTypeOnClickListener);

    try {
        ArrayList<Apartment> availableApartments = (ArrayList<Apartment>) DatabaseHandler.getAllApartments();
        for (Apartment apartment : availableApartments) {
            apartmentNames.add(apartment.getName());
        }
        Collections.sort(apartmentNames, compareToIgnoreCase);
    } catch (Exception e) {
        StatusMessageHandler.showErrorMessage(this, e);
    }

    ImageButton imageButtonSwitchApartment = (ImageButton) findViewById(R.id.imageButton_switchApartment);
    imageButtonSwitchApartment.setImageDrawable(new IconicsDrawable(this, MaterialDesignIconic.Icon.gmi_shuffle)
            .sizeDp(24).color(ContextCompat.getColor(this, android.R.color.white)));
    imageButtonSwitchApartment.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (useManualApartmentInput) {
                setApartmentInputType(InputType.LIST);
            } else {
                setApartmentInputType(InputType.MANUAL);
            }

            setPositiveButtonVisibility(checkValidity());
        }
    });

    spinner_apartment = (Spinner) findViewById(R.id.spinner_apartment);
    ArrayAdapter<String> apartmentSpinnerArrayAdapter = new ArrayAdapter<>(this,
            android.R.layout.simple_spinner_item, apartmentNames);
    apartmentSpinnerArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner_apartment.setAdapter(apartmentSpinnerArrayAdapter);
    SpinnerInteractionListener spinnerInteractionListener = new SpinnerInteractionListener() {
        @Override
        public void onItemSelectedByUser(AdapterView<?> parent, View view, int pos, long id) {
            updateLists();
            setPositiveButtonVisibility(checkValidity());
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
            setPositiveButtonVisibility(checkValidity());
        }
    };
    spinner_apartment.setOnTouchListener(spinnerInteractionListener);
    spinner_apartment.setOnItemSelectedListener(spinnerInteractionListener);

    editText_apartment = (EditText) findViewById(R.id.editText_apartment);
    editText_apartment.addTextChangedListener(editTextTextWatcher);

    linearLayoutRoom = (LinearLayout) findViewById(R.id.linearLayout_room);
    linearLayoutReceiver = (LinearLayout) findViewById(R.id.linearLayout_receiver);
    linearLayoutButton = (LinearLayout) findViewById(R.id.linearLayout_button);
    linearLayoutScene = (LinearLayout) findViewById(R.id.linearLayout_scene);

    ImageButton imageButtonSwitchRoom = (ImageButton) findViewById(R.id.imageButton_switchRoom);
    imageButtonSwitchRoom.setImageDrawable(new IconicsDrawable(this, MaterialDesignIconic.Icon.gmi_shuffle)
            .sizeDp(24).color(ContextCompat.getColor(this, android.R.color.white)));
    imageButtonSwitchRoom.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (useManualRoomInput) {
                setRoomInputType(InputType.LIST);
            } else {
                setRoomInputType(InputType.MANUAL);
            }

            setPositiveButtonVisibility(checkValidity());
        }
    });

    spinner_room = (Spinner) findViewById(R.id.spinner_room);
    roomSpinnerArrayAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, roomNames);
    roomSpinnerArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner_room.setAdapter(roomSpinnerArrayAdapter);
    spinnerInteractionListener = new SpinnerInteractionListener() {
        @Override
        public void onItemSelectedByUser(AdapterView<?> parent, View view, int pos, long id) {
            updateReceiverList();
            setPositiveButtonVisibility(checkValidity());
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
            setPositiveButtonVisibility(checkValidity());
        }
    };
    spinner_room.setOnTouchListener(spinnerInteractionListener);
    spinner_room.setOnItemSelectedListener(spinnerInteractionListener);

    editText_room = (EditText) findViewById(R.id.editText_room);
    editText_room.addTextChangedListener(editTextTextWatcher);

    ImageButton imageButtonSwitchReceiver = (ImageButton) findViewById(R.id.imageButton_switchReceiver);
    imageButtonSwitchReceiver.setImageDrawable(new IconicsDrawable(this, MaterialDesignIconic.Icon.gmi_shuffle)
            .sizeDp(24).color(ContextCompat.getColor(this, android.R.color.white)));
    imageButtonSwitchReceiver.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (useManualReceiverInput) {
                setReceiverInputType(InputType.LIST);
            } else {
                setReceiverInputType(InputType.MANUAL);
            }

            setPositiveButtonVisibility(checkValidity());
        }
    });

    spinner_receiver = (Spinner) findViewById(R.id.spinner_receiver);
    receiverSpinnerArrayAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, receiverNames);
    receiverSpinnerArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner_receiver.setAdapter(receiverSpinnerArrayAdapter);
    spinnerInteractionListener = new SpinnerInteractionListener() {
        @Override
        public void onItemSelectedByUser(AdapterView<?> parent, View view, int pos, long id) {
            updateButtonList();
            setPositiveButtonVisibility(checkValidity());
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
            setPositiveButtonVisibility(checkValidity());
        }
    };
    spinner_receiver.setOnTouchListener(spinnerInteractionListener);
    spinner_receiver.setOnItemSelectedListener(spinnerInteractionListener);

    editText_receiver = (EditText) findViewById(R.id.editText_receiver);
    editText_receiver.addTextChangedListener(editTextTextWatcher);

    ImageButton imageButtonSwitchButton = (ImageButton) findViewById(R.id.imageButton_switchButton);
    imageButtonSwitchButton.setImageDrawable(new IconicsDrawable(this, MaterialDesignIconic.Icon.gmi_shuffle)
            .sizeDp(24).color(ContextCompat.getColor(this, android.R.color.white)));
    imageButtonSwitchButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (useManualButtonInput) {
                setButtonInputType(InputType.LIST);
            } else {
                setButtonInputType(InputType.MANUAL);
            }

            setPositiveButtonVisibility(checkValidity());
        }
    });

    spinner_button = (Spinner) findViewById(R.id.spinner_button);
    buttonSpinnerArrayAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, buttonNames);
    buttonSpinnerArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner_button.setAdapter(buttonSpinnerArrayAdapter);
    spinnerInteractionListener = new SpinnerInteractionListener() {
        @Override
        public void onItemSelectedByUser(AdapterView<?> parent, View view, int pos, long id) {
            setPositiveButtonVisibility(checkValidity());
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
            setPositiveButtonVisibility(checkValidity());
        }
    };
    spinner_button.setOnTouchListener(spinnerInteractionListener);
    spinner_button.setOnItemSelectedListener(spinnerInteractionListener);

    editText_button = (EditText) findViewById(R.id.editText_button);
    editText_button.addTextChangedListener(editTextTextWatcher);

    ImageButton imageButtonSwitchScene = (ImageButton) findViewById(R.id.imageButton_switchScene);
    imageButtonSwitchScene.setImageDrawable(new IconicsDrawable(this, MaterialDesignIconic.Icon.gmi_shuffle)
            .sizeDp(24).color(ContextCompat.getColor(this, android.R.color.white)));
    imageButtonSwitchScene.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (useManualSceneInput) {
                setSceneInputType(InputType.LIST);
            } else {
                setSceneInputType(InputType.MANUAL);
            }

            setPositiveButtonVisibility(checkValidity());
        }
    });

    spinner_scene = (Spinner) findViewById(R.id.spinner_scene);
    sceneSpinnerArrayAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, sceneNames);
    sceneSpinnerArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner_scene.setAdapter(sceneSpinnerArrayAdapter);
    spinnerInteractionListener = new SpinnerInteractionListener() {
        @Override
        public void onItemSelectedByUser(AdapterView<?> parent, View view, int pos, long id) {
            setPositiveButtonVisibility(checkValidity());
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
            setPositiveButtonVisibility(checkValidity());
        }
    };
    spinner_scene.setOnTouchListener(spinnerInteractionListener);
    spinner_scene.setOnItemSelectedListener(spinnerInteractionListener);

    editText_scene = (EditText) findViewById(R.id.editText_scene);
    editText_scene.addTextChangedListener(editTextTextWatcher);

    updateLists();

    BundleScrubber.scrub(getIntent());
    final Bundle localeBundle = getIntent().getBundleExtra(com.twofortyfouram.locale.Intent.EXTRA_BUNDLE);
    BundleScrubber.scrub(localeBundle);

    if (null == savedInstanceState && PluginBundleManager.isBundleValid(this, localeBundle)) {
        initData(localeBundle);
    } else {
        updateActionType(Action.ACTION_TYPE_RECEIVER);
    }

    setPositiveButtonVisibility(checkValidity());
}

From source file:com.mifos.mifosxdroid.online.LoanAccountFragment.java

private void inflateLoanOfficerSpinner() {
    showProgress(true);//w w  w.  j a va  2  s.co  m
    App.apiManager.getLoansAccountTemplate(clientId, productId, new Callback<Response>() {
        @Override

        public void success(final Response result, Response response) {
            /* Activity is null - Fragment has been detached; no need to do anything. */
            if (getActivity() == null)
                return;

            Log.d(LOG_TAG, "");

            final List<FieldOfficerOptions> loanOfficer = new ArrayList<>();
            // you can use this array to populate your spinner
            final ArrayList<String> loanOfficerNames = new ArrayList<String>();
            //Try to get response body
            BufferedReader reader = null;
            StringBuilder sb = new StringBuilder();
            try {
                reader = new BufferedReader(new InputStreamReader(result.getBody().in()));
                String line;
                while ((line = reader.readLine()) != null) {
                    sb.append(line);
                }
                JSONObject obj = new JSONObject(sb.toString());
                if (obj.has("loanOfficerOptions")) {
                    JSONArray loanOfficers = obj.getJSONArray("loanOfficerOptions");
                    for (int i = 0; i < loanOfficers.length(); i++) {
                        JSONObject fieldOfficerObject = loanOfficers.getJSONObject(i);
                        FieldOfficerOptions officer = new FieldOfficerOptions();
                        officer.setId(fieldOfficerObject.optInt("id"));
                        officer.setDisplayName(fieldOfficerObject.optString("displayName"));
                        loanOfficer.add(officer);
                        loanOfficerNames.add(fieldOfficerObject.optString("displayName"));
                        loanOfficerNameIdHashMap.put(officer.getDisplayName(), officer.getId());
                    }

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

            sp_loan_officer.setAdapter(loanOfficerNameAdapter);
            sp_loan_officer.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
                @Override
                public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
                    loanOfficerId = loanOfficerNameIdHashMap.get(loanOfficerNames.get(i));
                    Log.d("loanOfficer " + loanOfficerNames.get(i), String.valueOf(loanOfficerId));
                    if (loanOfficerId != -1) {

                    } else {

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

                    }

                }

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

                }
            });

            showProgress(false);

        }

        @Override
        public void failure(RetrofitError retrofitError) {

            Log.d(LOG_TAG, retrofitError.getLocalizedMessage());

            showProgress(false);
        }
    });
}

From source file:com.mifos.mifosxdroid.online.LoanAccountFragment.java

private void inflateInterestTypeMethodSpinner() {
    showProgress(true);//from www  .  jav a2s.c o  m
    App.apiManager.getLoansAccountTemplate(clientId, productId, new Callback<Response>() {
        @Override

        public void success(final Response result, Response response) {
            /* Activity is null - Fragment has been detached; no need to do anything. */
            if (getActivity() == null)
                return;

            Log.d(LOG_TAG, "");

            final List<InterestType> interestType = new ArrayList<>();
            // you can use this array to populate your spinner
            final ArrayList<String> interestTypeNames = new ArrayList<String>();
            //Try to get response body
            BufferedReader reader = null;
            StringBuilder sb = new StringBuilder();
            try {
                reader = new BufferedReader(new InputStreamReader(result.getBody().in()));
                String line;
                while ((line = reader.readLine()) != null) {
                    sb.append(line);
                }
                JSONObject obj = new JSONObject(sb.toString());
                if (obj.has("interestTypeOptions")) {
                    JSONArray interestTypes = obj.getJSONArray("interestTypeOptions");
                    for (int i = 0; i < interestTypes.length(); i++) {
                        JSONObject interestTypeObject = interestTypes.getJSONObject(i);
                        InterestType interest = new InterestType();
                        interest.setId(interestTypeObject.optInt("id"));
                        interest.setValue(interestTypeObject.optString("value"));
                        interestType.add(interest);
                        interestTypeNames.add(interestTypeObject.optString("value"));
                        interestTypeIdHashMap.put(interest.getValue(), interest.getId());
                    }

                }
                String stringResult = sb.toString();
            } catch (Exception e) {
                Log.e(LOG_TAG, "", e);
            }
            final ArrayAdapter<String> interestTypeMethodAdapter = new ArrayAdapter<>(getActivity(),
                    layout.simple_spinner_item, interestTypeNames);
            interestTypeMethodAdapter.setDropDownViewResource(layout.simple_spinner_dropdown_item);
            sp_interest_type.setAdapter(interestTypeMethodAdapter);
            sp_interest_type.setOnItemSelectedListener(new OnItemSelectedListener() {
                @Override
                public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
                    interestTypeId = interestTypeIdHashMap.get(interestTypeNames.get(i));
                    Log.d("interestType " + interestTypeNames.get(i), String.valueOf(interestTypeId));
                    if (interestTypeId != -1) {

                    } else {

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

                    }

                }

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

                }
            });

            showProgress(false);

        }

        @Override
        public void failure(RetrofitError retrofitError) {

            Log.d(LOG_TAG, retrofitError.getLocalizedMessage());

            showProgress(false);
        }
    });
}

From source file:com.mifos.mifosxdroid.online.LoanAccountFragment.java

private void inflateLoanPurposeSpinner() {
    showProgress(true);//from   ww  w. j  a  va2  s  .  com
    App.apiManager.getLoansAccountTemplate(clientId, productId, new Callback<Response>() {
        @Override

        public void success(final Response result, Response response) {
            /* Activity is null - Fragment has been detached; no need to do anything. */
            if (getActivity() == null)
                return;

            Log.d(LOG_TAG, "");

            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.getBody().in()));
                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) {

                }
            });

            showProgress(false);

        }

        @Override
        public void failure(RetrofitError retrofitError) {

            Log.d(LOG_TAG, retrofitError.getLocalizedMessage());

            showProgress(false);
        }
    });
}

From source file:com.mifos.mifosxdroid.online.LoanAccountFragment.java

private void inflateAmortizationSpinner() {
    showProgress(true);/*from ww  w .  j ava2 s. c o m*/
    App.apiManager.getLoansAccountTemplate(clientId, productId, new Callback<Response>() {
        @Override

        public void success(final Response result, Response response) {
            /* Activity is null - Fragment has been detached; no need to do anything. */
            if (getActivity() == null)
                return;

            Log.d(LOG_TAG, "");

            final List<AmortizationType> amortizationType = new ArrayList<>();
            // you can use this array to populate your spinner
            final ArrayList<String> amortizationTypeNames = new ArrayList<String>();
            //Try to get response body
            BufferedReader reader = null;
            StringBuilder sb = new StringBuilder();
            try {
                reader = new BufferedReader(new InputStreamReader(result.getBody().in()));
                String line;
                while ((line = reader.readLine()) != null) {
                    sb.append(line);
                }
                JSONObject obj = new JSONObject(sb.toString());
                if (obj.has("amortizationTypeOptions")) {
                    JSONArray amortizationTypes = obj.getJSONArray("amortizationTypeOptions");
                    for (int i = 0; i < amortizationTypes.length(); i++) {
                        JSONObject amortizationTypeObject = amortizationTypes.getJSONObject(i);
                        AmortizationType amortization = new AmortizationType();
                        amortization.setId(amortizationTypeObject.optInt("id"));
                        amortization.setValue(amortizationTypeObject.optString("value"));
                        amortizationType.add(amortization);
                        amortizationTypeNames.add(amortizationTypeObject.optString("value"));
                        amortizationTypeIdHashMap.put(amortization.getValue(), amortization.getId());
                    }

                }
                String stringResult = sb.toString();
            } catch (Exception e) {
                Log.e(LOG_TAG, "", e);
            }
            final ArrayAdapter<String> amortizationTypeAdapter = new ArrayAdapter<>(getActivity(),
                    layout.simple_spinner_item, amortizationTypeNames);
            amortizationTypeAdapter.setDropDownViewResource(layout.simple_spinner_dropdown_item);
            sp_amortization.setAdapter(amortizationTypeAdapter);
            sp_amortization.setOnItemSelectedListener(new OnItemSelectedListener() {
                @Override
                public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
                    amortizationTypeId = amortizationTypeIdHashMap.get(amortizationTypeNames.get(i));
                    Log.d("ammortization" + amortizationTypeNames.get(i), String.valueOf(amortizationTypeId));
                    if (amortizationTypeId != -1) {

                    } else {

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

                    }

                }

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

                }
            });

            showProgress(false);

        }

        @Override
        public void failure(RetrofitError retrofitError) {

            Log.d(LOG_TAG, retrofitError.getLocalizedMessage());

            showProgress(false);
        }
    });
}

From source file:com.mifos.mifosxdroid.online.LoanAccountFragment.java

private void inflateFrequencyPeriodSpinner() {
    showProgress(true);/*ww w . j av  a 2s.c  om*/
    App.apiManager.getLoansAccountTemplate(clientId, productId, new Callback<Response>() {
        @Override

        public void success(final Response result, Response response) {
            /* Activity is null - Fragment has been detached; no need to do anything. */
            if (getActivity() == null)
                return;

            Log.d(LOG_TAG, "");

            final List<TermFrequencyTypeOptions> termFrequencyType = new ArrayList<>();
            // you can use this array to populate your spinner
            final ArrayList<String> termFrequencyTypeNames = new ArrayList<String>();
            //Try to get response body
            BufferedReader reader = null;
            StringBuilder sb = new StringBuilder();
            try {
                reader = new BufferedReader(new InputStreamReader(result.getBody().in()));
                String line;
                while ((line = reader.readLine()) != null) {
                    sb.append(line);
                }
                JSONObject obj = new JSONObject(sb.toString());
                if (obj.has("termFrequencyTypeOptions")) {
                    JSONArray termFrequencyTypes = obj.getJSONArray("termFrequencyTypeOptions");
                    for (int i = 0; i < termFrequencyTypes.length(); i++) {
                        JSONObject termFrequencyTypeObject = termFrequencyTypes.getJSONObject(i);
                        TermFrequencyTypeOptions termFrequency = new TermFrequencyTypeOptions();
                        termFrequency.setId(termFrequencyTypeObject.optInt("id"));
                        termFrequency.setValue(termFrequencyTypeObject.optString("value"));
                        termFrequencyType.add(termFrequency);
                        termFrequencyTypeNames.add(termFrequencyTypeObject.optString("value"));
                        termFrequencyTypeIdHashMap.put(termFrequency.getValue(), termFrequency.getId());
                    }

                }
                String stringResult = sb.toString();
            } catch (Exception e) {
                Log.e(LOG_TAG, "", e);
            }
            final ArrayAdapter<String> termFrequencyTypeAdapter = new ArrayAdapter<>(getActivity(),
                    layout.simple_spinner_item, termFrequencyTypeNames);
            termFrequencyTypeAdapter.setDropDownViewResource(layout.simple_spinner_dropdown_item);
            sp_payment_periods.setAdapter(termFrequencyTypeAdapter);
            sp_payment_periods.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
                @Override
                public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
                    loanTermFrequency = termFrequencyTypeIdHashMap.get(termFrequencyTypeNames.get(i));
                    Log.d("loanTermFrequency" + termFrequencyTypeNames.get(i),
                            String.valueOf(loanTermFrequency));
                    if (loanTermFrequency != -1) {

                    } else {

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

                    }

                }

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

                }
            });

            showProgress(false);

        }

        @Override
        public void failure(RetrofitError retrofitError) {

            Log.d(LOG_TAG, retrofitError.getLocalizedMessage());

            showProgress(false);
        }
    });
}

From source file:com.androguide.honamicontrol.kernel.cpucontrol.CPUActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //noinspection ConstantConditions
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setIcon(getResources().getDrawable(R.drawable.ic_tools_cpu_control));
    setContentView(R.layout.card_cpu_control);
    bootPrefs = getSharedPreferences("BOOT_PREFS", 0);

    graph = (LineGraph) findViewById(R.id.graph);
    line = new Line();
    LinePoint point = new LinePoint();
    point.setX(currX);/* w  ww.  j  a  v  a2  s . com*/
    point.setY(1);
    line.addPoint(point);
    line.setColor(Color.parseColor("#FFBB33"));
    graph.addLine(line);
    graph.setLineToFill(0);

    availableFrequencies = new String[0];
    String availableFrequenciesLine;

    mCoresOnline = (TextView) findViewById(R.id.cores_online);
    mGeneralGovernor = (Spinner) findViewById(R.id.general_governor);
    mGovernor = (Spinner) findViewById(R.id.governor);
    mGovernor2 = (Spinner) findViewById(R.id.governor2);
    mGovernor3 = (Spinner) findViewById(R.id.governor3);
    mGovernor4 = (Spinner) findViewById(R.id.governor4);

    Button customizeGov = (Button) findViewById(R.id.governor_customize_btn);
    customizeGov.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            FragmentManager fm = getSupportFragmentManager();
            GovernorDialog editNameDialog = new GovernorDialog();
            editNameDialog.show(fm, "governor_fragment");
        }
    });

    if (Helpers.doesFileExist(STEPS)) {
        availableFrequenciesLine = CPUHelper.readOneLineNotRoot(STEPS);

        if (availableFrequenciesLine != null) {
            availableFrequencies = availableFrequenciesLine.split(" ");
            Arrays.sort(availableFrequencies, new Comparator<String>() {
                @Override
                public int compare(String object1, String object2) {
                    return Integer.valueOf(object1).compareTo(Integer.valueOf(object2));
                }
            });
        }
    }

    Switch snakeCharmer = (Switch) findViewById(R.id.snake_charmer_switch);
    if (!Helpers.doesFileExist(SNAKE_CHARMER_MAX_FREQ)) {
        LinearLayout cardSnakeCharmer = (LinearLayout) findViewById(R.id.card_snake_charmer);
        cardSnakeCharmer.setVisibility(View.GONE);
    } else {
        if (Helpers.doesFileExist(SNAKE_CHARMER_VERSION)) {
            TextView snakeTitle = (TextView) findViewById(R.id.snake_charmer);
            String snakeVersion = CPUHelper.readOneLineNotRoot(SNAKE_CHARMER_VERSION);
            snakeVersion = snakeVersion.replaceAll("version: ", "v");
            snakeTitle.setText(snakeTitle.getText() + " " + snakeVersion);
            if (snakeVersion.equals("v1.2")) {
                TextView snakeDesc = (TextView) findViewById(R.id.snake_charmer_text);
                snakeDesc.setText(snakeDesc.getText() + "\n" + getString(R.string.snake_charmer_built_in));
                snakeCharmer.setEnabled(false);
            }
        }

        if (bootPrefs.getBoolean("SNAKE_CHARMER", true)) {
            snakeCharmer.setChecked(true);
            snakeCharmerEnabled = true;
        }

        snakeCharmer.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton compoundButton, boolean isOn) {
                snakeCharmerEnabled = isOn;
            }
        });
    }

    int frequenciesNum = availableFrequencies.length - 1;

    Switch thermalControl = (Switch) findViewById(R.id.msm_thermal_switch);
    if (Helpers.doesFileExist(MSM_THERMAL)) {
        String thermal = CPUHelper.readOneLineNotRoot(MSM_THERMAL);
        if (thermal.equals("Y"))
            thermalControl.setChecked(true);
        else
            thermalControl.setChecked(false);

        thermalControl.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {
                if (isChecked)
                    Helpers.CMDProcessorWrapper.runSuCommand("echo Y > " + MSM_THERMAL);
                else
                    Helpers.CMDProcessorWrapper.runSuCommand("echo N > " + MSM_THERMAL);

                bootPrefs.edit().putBoolean("MSM_THERMAL", isChecked).commit();
            }
        });
    }
    thermalControl.setChecked(bootPrefs.getBoolean("MSM_THERMAL", true));

    perCoreGovernor = (Switch) findViewById(R.id.per_core_governors_switch);
    perCoreGovernor.setChecked(bootPrefs.getBoolean("PER_CORE_GOV", true));

    if (perCoreGovernor.isChecked()) {
        findViewById(R.id.card_general_governor).setVisibility(View.GONE);
        findViewById(R.id.card_per_core_governors).setVisibility(View.VISIBLE);
    } else {
        findViewById(R.id.card_per_core_governors).setVisibility(View.GONE);
        findViewById(R.id.card_general_governor).setVisibility(View.VISIBLE);
    }

    perCoreGovernor.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {
            if (isChecked) {
                findViewById(R.id.card_general_governor).setVisibility(View.GONE);
                findViewById(R.id.card_per_core_governors).setVisibility(View.VISIBLE);
                handleGovernors();
            } else {
                findViewById(R.id.card_per_core_governors).setVisibility(View.GONE);
                findViewById(R.id.card_general_governor).setVisibility(View.VISIBLE);
                handleGovernors();
            }

            bootPrefs.edit().putBoolean("PER_CORE_GOV", isChecked).commit();
        }
    });

    String currentIo = "";
    if (Helpers.doesFileExist(IO_SCHEDULER))
        currentIo = CPUHelper.getIOScheduler();

    String currentTcp = "";
    if (Helpers.doesFileExist(CURR_TCP_ALGORITHM))
        currentTcp = Helpers.getCurrentTcpAlgorithm();

    String curMaxSpeed = "NaN";
    if (Helpers.doesFileExist(MAX_FREQ_ALL_CORES))
        curMaxSpeed = CPUHelper.readOneLineNotRoot(MAX_FREQ_ALL_CORES);
    else if (Helpers.doesFileExist(MAX_FREQ))
        curMaxSpeed = CPUHelper.readOneLineNotRoot(MAX_FREQ);

    String curMinSpeed = "NaN";
    if (Helpers.doesFileExist(MIN_FREQ_ALL_CORES))
        curMinSpeed = CPUHelper.readOneLineNotRoot(MIN_FREQ_ALL_CORES);
    else if (Helpers.doesFileExist(MIN_FREQ))
        curMinSpeed = CPUHelper.readOneLineNotRoot(MIN_FREQ);

    if (mIsTegra3) {
        String curTegraMaxSpeed = "NaN";
        if (Helpers.doesFileExist(TEGRA_MAX_FREQ)) {
            curTegraMaxSpeed = CPUHelper.readOneLineNotRoot(TEGRA_MAX_FREQ);
            int curTegraMax = 0;
            try {
                curTegraMax = Integer.parseInt(curTegraMaxSpeed);
                if (curTegraMax > 0) {
                    curMaxSpeed = Integer.toString(curTegraMax);
                }
            } catch (NumberFormatException ex) {
                curTegraMax = 0;
            }
        }
    }

    if (Helpers.doesFileExist(NUM_OF_CPUS))
        mNumOfCpus = Helpers.getNumOfCpus();

    mCurFreq = (TextView) findViewById(R.id.currspeed);

    mMaxSlider = (SeekBar) findViewById(R.id.max_slider);
    mMaxSlider.setMax(frequenciesNum);
    mMaxSpeedText = (TextView) findViewById(R.id.max_speed_text);
    mMaxSpeedText.setText(toMHz(curMaxSpeed));
    mMaxSlider.setProgress(Arrays.asList(availableFrequencies).indexOf(curMaxSpeed));
    mMaxSlider.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            if (fromUser)
                setMaxSpeed(seekBar, progress);
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {

        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            startSupportActionMode(new ActionMode.Callback() {
                @Override
                public boolean onCreateActionMode(ActionMode actionMode, Menu menu) {
                    MenuInflater inflater = actionMode.getMenuInflater();
                    inflater.inflate(R.menu.contextual_menu, menu);
                    return true;
                }

                @Override
                public boolean onPrepareActionMode(ActionMode actionMode, Menu menu) {
                    return false;
                }

                @Override
                public boolean onActionItemClicked(ActionMode actionMode, MenuItem menuItem) {
                    switch (menuItem.getItemId()) {
                    case R.id.apply:
                        if (mMaxFreqSetting != null && !mMaxFreqSetting.isEmpty()) {
                            bootPrefs.edit().putString("CPU_MAX_FREQ", mMaxFreqSetting).commit();
                            for (int i = 0; i < mNumOfCpus; i++)
                                Helpers.CMDProcessorWrapper.runSuCommand("busybox echo " + mMaxFreqSetting
                                        + " > " + MAX_FREQ.replace("cpu0", "cpu" + i));

                            if (snakeCharmerEnabled)
                                Helpers.CMDProcessorWrapper.runSuCommand(
                                        "busybox echo " + mMaxFreqSetting + " > " + SNAKE_CHARMER_MAX_FREQ);
                        }

                        if (mIsTegra3) {
                            if (mMaxFreqSetting != null && !mMaxFreqSetting.isEmpty())
                                Helpers.CMDProcessorWrapper.runSuCommand(
                                        "busybox echo " + mMaxFreqSetting + " > " + TEGRA_MAX_FREQ);

                            if (snakeCharmerEnabled)
                                Helpers.CMDProcessorWrapper.runSuCommand(
                                        "busybox echo " + mMaxFreqSetting + " > " + SNAKE_CHARMER_MAX_FREQ);
                        }
                        actionMode.finish();
                        return true;
                    default:
                        return false;
                    }
                }

                @Override
                public void onDestroyActionMode(ActionMode actionMode) {

                }
            });
        }
    });

    mMinSlider = (SeekBar) findViewById(R.id.min_slider);
    mMinSlider.setMax(frequenciesNum);
    mMinSpeedText = (TextView) findViewById(R.id.min_speed_text);
    mMinSpeedText.setText(toMHz(curMinSpeed));
    mMinSlider.setProgress(Arrays.asList(availableFrequencies).indexOf(curMinSpeed));
    mMinSlider.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            if (fromUser)
                setMinSpeed(seekBar, progress);
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {

        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            startSupportActionMode(new ActionMode.Callback() {
                @Override
                public boolean onCreateActionMode(ActionMode actionMode, Menu menu) {
                    MenuInflater inflater = actionMode.getMenuInflater();
                    inflater.inflate(R.menu.contextual_menu, menu);
                    return true;
                }

                @Override
                public boolean onPrepareActionMode(ActionMode actionMode, Menu menu) {
                    return false;
                }

                @Override
                public boolean onActionItemClicked(ActionMode actionMode, MenuItem menuItem) {
                    switch (menuItem.getItemId()) {
                    case R.id.apply:
                        if (mMinFreqSetting != null && !mMinFreqSetting.isEmpty()) {
                            bootPrefs.edit().putString("CPU_MIN_FREQ", mMinFreqSetting).commit();
                            for (int i = 0; i < mNumOfCpus; i++)
                                Helpers.CMDProcessorWrapper.runSuCommand("busybox echo " + mMinFreqSetting
                                        + " > " + MIN_FREQ.replace("cpu0", "cpu" + i));
                        }
                        actionMode.finish();
                        return true;
                    default:
                        return false;
                    }
                }

                @Override
                public void onDestroyActionMode(ActionMode actionMode) {

                }
            });
        }
    });

    handleGovernors();

    /** TCP Congestion Spinner */
    Spinner mTcp = (Spinner) findViewById(R.id.tcp);
    ArrayAdapter<CharSequence> tcpAdapter = new ArrayAdapter<CharSequence>(this, R.layout.spinner_row);
    tcpAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    ArrayList<String> algorithms = Helpers.getTcpAlgorithms();
    for (String algorithm : algorithms)
        tcpAdapter.add(algorithm);
    mTcp.setAdapter(tcpAdapter);
    mTcp.setSelection(algorithms.indexOf(currentTcp));
    mTcp.setOnItemSelectedListener(new TCPListener());

    onlineCoresPolling();
}

From source file:nf.frex.android.FrexActivity.java

private void preparePropertiesDialog(final Dialog dialog) {

    final Registry<Fractal> fractals = Registries.fractals;
    int fractalTypeIndex = fractals.getIndex(view.getFractalId());

    final Spinner fractalTypeSpinner = (Spinner) dialog.findViewById(R.id.fractal_type_spinner);
    final SeekBar iterationsSeekBar = (SeekBar) dialog.findViewById(R.id.num_iterations_seek_bar);
    final EditText iterationsEditText = (EditText) dialog.findViewById(R.id.num_iterations_edit_text);
    final CheckBox juliaModeCheckBox = (CheckBox) dialog.findViewById(R.id.julia_mode_fractal_check_box);
    final CheckBox decoratedFractal = (CheckBox) dialog.findViewById(R.id.decorated_fractal_check_box);
    final Button okButton = (Button) dialog.findViewById(R.id.ok_button);
    final Button cancelButton = (Button) dialog.findViewById(R.id.cancel_button);

    juliaModeCheckBox.setEnabled(true);//from   ww  w  . ja  va  2 s .  com

    ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item,
            fractals.getIds());
    arrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    fractalTypeSpinner.setAdapter(arrayAdapter);
    fractalTypeSpinner.setSelection(fractalTypeIndex, true);
    fractalTypeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View spinnerView, int position, long id) {
            Fractal fractal = fractals.getValue(position);
            iterationsEditText.setText(fractal.getDefaultIterMax() + "");
            boolean sameFractal = view.getFractalId().equals(fractals.getId(position));
            if (!sameFractal) {
                juliaModeCheckBox.setChecked(false);
            }
            juliaModeCheckBox.setEnabled(sameFractal);
        }

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

    iterationsEditText.setText(view.getIterMax() + "", TextView.BufferType.NORMAL);

    final double iterationsMin = 1;
    final double iterationsMax = 3;
    final SeekBarConfigurer iterationsSeekBarConfigurer = SeekBarConfigurer.create(iterationsSeekBar,
            iterationsMin, iterationsMax, true, view.getIterMax());
    iterationsSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            if (fromUser) {
                int iterMax = iterationsSeekBarConfigurer.getValueInt();
                iterationsEditText.setText(iterMax + "", TextView.BufferType.NORMAL);
            }
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
        }
    });

    iterationsEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            try {
                int iterMax = Integer.parseInt(v.getText().toString());
                iterationsSeekBarConfigurer.setValue(iterMax);
                return true;
            } catch (NumberFormatException e) {
                return false;
            }
        }
    });

    decoratedFractal.setChecked(view.isDecoratedFractal());

    juliaModeCheckBox.setChecked(view.isJuliaModeFractal());

    okButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            int iterMax;
            try {
                iterMax = Integer.parseInt(iterationsEditText.getText().toString());
            } catch (NumberFormatException e) {
                Toast.makeText(FrexActivity.this, getString(R.string.error_msg, e.getLocalizedMessage()),
                        Toast.LENGTH_SHORT).show();
                return;
            }
            dialog.dismiss();
            String oldConfigName = view.getConfigName();
            String newFractalId = fractals.getId(fractalTypeSpinner.getSelectedItemPosition());
            Fractal fractal = fractals.getValue(fractalTypeSpinner.getSelectedItemPosition());
            String oldFractalId = view.getFractalId();
            boolean newJuliaModeFractal = juliaModeCheckBox.isChecked();
            boolean oldJuliaModeFractal = view.isJuliaModeFractal();
            view.setFractalId(newFractalId);
            view.setIterMax(iterMax);
            view.setDecoratedFractal(decoratedFractal.isChecked());
            view.setJuliaModeFractal(newJuliaModeFractal);
            boolean fractalTypeChanged = !oldFractalId.equals(newFractalId);
            if (fractalTypeChanged) {
                if (oldConfigName.contains(oldFractalId.toLowerCase())) {
                    view.setConfigName(newFractalId.toLowerCase());
                }
                view.setRegion(fractal.getDefaultRegion());
                view.setBailOut(fractal.getDefaultBailOut());
            }
            boolean juliaModeChanged = oldJuliaModeFractal != newJuliaModeFractal;
            if (fractalTypeChanged || juliaModeChanged) {
                view.getRegionHistory().clear();
                view.getRegionHistory().add(fractal.getDefaultRegion().clone());
            }
            view.recomputeAll();
        }
    });
    cancelButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            dialog.dismiss();
        }
    });
}

From source file:com.imaginamos.taxisya.taxista.activities.RegisterDriverActivity.java

public void prepareSpinners() {

    // set spinner
    mCountrySpinner = (Spinner) findViewById(R.id.spinner_country);

    mDepartmentSpinner = (Spinner) findViewById(R.id.spinner_department);

    mCitiesSpinner = (Spinner) findViewById(R.id.spinner_city);

    ArrayAdapter spinnerArrayAdapter = new ArrayAdapter(this, android.R.layout.simple_spinner_item,
            countriesArray);/*from  w  ww. j a  v  a 2 s. co m*/
    spinnerArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); // The drop down view
    mCountrySpinner.setAdapter(spinnerArrayAdapter);

    mCountrySpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        public void onItemSelected(AdapterView parent, View view, int pos, long log) {

            Country item = (Country) parent.getItemAtPosition(pos);

            Log.v("UPDATE_DATA", "spinner country" + String.valueOf(item.getId() + " " + item.getName()));

            int departmentId = firstDepartment(item.getId());
            updateDepartment(item.getId());
            updateCities(departmentId);

        }

        public void onNothingSelected(AdapterView arg0) {

        }
    });

    mDepartmentSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        public void onItemSelected(AdapterView parent, View view, int pos, long log) {

            Department item = (Department) parent.getItemAtPosition(pos);

            int departmentId = item.getId();

            Log.v("UPDATE_DATA", "spinner department" + String.valueOf(item.getId() + " " + item.getName()));

            updateCities(departmentId);

        }

        public void onNothingSelected(AdapterView arg0) {

        }
    });

    mCitiesSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        public void onItemSelected(AdapterView parent, View view, int pos, long log) {

            City item = (City) parent.getItemAtPosition(pos);

            Log.v("UPDATE_DATA", "spinner city" + String.valueOf(item.getId() + " " + item.getName()));

            mCityId = item.getId();

        }

        public void onNothingSelected(AdapterView arg0) {

        }
    });

    int countryId = countriesArray.get(0).getId();
    int departmentId = firstDepartment(countryId);

    Log.v("UPDATE_DATA", " ++++++++++++++++++++++++++++++ ");
    Log.v("UPDATE_DATA", " countryId: " + String.valueOf(countryId));
    Log.v("UPDATE_DATA", " departmentId: " + String.valueOf(departmentId));

    updateDepartment(countryId);

    updateCities(departmentId);

}

From source file:com.jbsoft.farmtotable.FarmToTableActivity.java

private void initListNav() {
    ArrayList<String> items = new ArrayList<String>();
    ArrayAdapter<String> nav = null;
    ActionBar bar = getSupportActionBar();

    for (int type : MAP_TYPE_NAMES) {
        items.add(getString(type));// www .j  a  va 2s.co  m
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        nav = new ArrayAdapter<String>(bar.getThemedContext(), android.R.layout.simple_spinner_item, items);
    } else {
        nav = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, items);
    }

    nav.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    bar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
}