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.farbod.labelledspinner.LabelledSpinner.java

/**
 * Sets the array of items to be used in the Spinner.
 *
 * @param list The list to be used as the data source.
 * @param spinnerItemRes The identifier of the layout used to create
 *                       views (e.g. {@code R.layout.my_item})
 * @param dropdownViewRes The layout resource to create the drop down
 *                        views (e.g. {@code R.layout.my_dropdown})
 *
 * @see #setItemsArray(int)/*from   w  w w . j  a v a 2 s  .co m*/
 * @see #setItemsArray(int, int, int)
 * @see #setItemsArray(CharSequence[])
 * @see #setItemsArray(CharSequence[], int, int)
 * @see #setItemsArray(List)
 *
 * @attr ref R.styleable#LabelledSpinner_entries
 */
public void setItemsArray(List<?> list, @LayoutRes int spinnerItemRes, @LayoutRes int dropdownViewRes) {
    ArrayAdapter<?> adapter = new ArrayAdapter<>(getContext(), spinnerItemRes, list);
    adapter.setDropDownViewResource(dropdownViewRes);
    mSpinner.setAdapter(adapter);
}

From source file:net.majorkernelpanic.spydroid.ClientActivity.java

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

    setContentView(R.layout.client);/*from   ww  w  .  j  a  v  a  2s  .  c  o  m*/

    editTextIP = (EditText) findViewById(R.id.server_ip);
    layoutContainer = (FrameLayout) findViewById(R.id.video_container);
    layoutForm = (RelativeLayout) findViewById(R.id.form);
    layoutControl = (RelativeLayout) findViewById(R.id.control);
    progressBar = (ProgressBar) findViewById(R.id.progress);

    audioStream = new MediaPlayer();

    // Initiate connection with client
    findViewById(R.id.button_connect).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            Editor editor = settings.edit();
            editor.putString("last_server_ip", editTextIP.getText().toString());
            editor.commit();
            layoutForm.setVisibility(View.GONE);
            progressBar.setVisibility(View.VISIBLE);
            getCurrentConfiguration();
        }
    });

    // Interrupt connection with the client
    findViewById(R.id.button_stop).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            stopStreaming();
            layoutControl.setVisibility(View.GONE);
            layoutForm.setVisibility(View.VISIBLE);
            progressBar.setVisibility(View.GONE);
        }
    });

    // Show configuration panel
    findViewById(R.id.button_config).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            findViewById(R.id.settings).setVisibility(View.VISIBLE);
        }
    });

    findViewById(R.id.reconnect).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            findViewById(R.id.settings).setVisibility(View.GONE);
            updateSettings();
        }
    });

    // Resolution
    Spinner spinner = (Spinner) findViewById(R.id.spinner1);
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.videoResolutionArray,
            android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(adapter);

    // Framerate
    spinner = (Spinner) findViewById(R.id.spinner2);
    adapter = ArrayAdapter.createFromResource(this, R.array.videoFramerateArray,
            android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(adapter);
    spinner.setOnItemSelectedListener(this);

    // Bitrate
    spinner = (Spinner) findViewById(R.id.spinner3);
    adapter = ArrayAdapter.createFromResource(this, R.array.videoBitrateArray,
            android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(adapter);
    spinner.setOnItemSelectedListener(this);

    // Video Encoder
    spinner = (Spinner) findViewById(R.id.spinner4);
    adapter = ArrayAdapter.createFromResource(this, R.array.videoEncoderArray,
            android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(adapter);
    spinner.setOnItemSelectedListener(this);

    // Audio Encoder
    spinner = (Spinner) findViewById(R.id.spinner5);
    adapter = ArrayAdapter.createFromResource(this, R.array.audioEncoderArray,
            android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(adapter);
    spinner.setOnItemSelectedListener(this);

    settings = PreferenceManager.getDefaultSharedPreferences(this);
    editTextIP.setText(settings.getString("last_server_ip", "192.168.0.107"));

}

From source file:com.rsmsa.accapp.ScreenSlidePageFragmentTwo.java

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

    tab_one = (EditText) rootView.findViewById(R.id.dob_one);

    vehicle_category = (Spinner) rootView.findViewById(R.id.vtype_spinner);

    vehicle_type = (Button) rootView.findViewById(R.id.vehicle_type_select_button);

    /**//w  w  w  . j  a v a2s  .  c  o m
     * Defining all layout items
     **/

    inputFatal = (EditText) rootView.findViewById(R.id.fatal_edit);
    inputInjuries = (EditText) rootView.findViewById(R.id.injury_edit);
    inputSimple = (EditText) rootView.findViewById(R.id.simple_edit);
    inputNotInjured = (EditText) rootView.findViewById(R.id.not_injured_edit);

    //driver 0ne details
    surname_one = (EditText) rootView.findViewById(R.id.surname_one);
    othernames_one = (EditText) rootView.findViewById(R.id.othernames_one);
    physical_address_one = (EditText) rootView.findViewById(R.id.physical_address_one);
    address_box_one = (EditText) rootView.findViewById(R.id.address_box_one);
    national_id_one = (EditText) rootView.findViewById(R.id.national_id_one);
    phone_no_one = (EditText) rootView.findViewById(R.id.phone_no_one);
    final RadioButton male = (RadioButton) rootView.findViewById(R.id.male);
    final RadioButton female = (RadioButton) rootView.findViewById(R.id.female);
    nationality_one = (EditText) rootView.findViewById(R.id.nationality_one);
    license_one = (EditText) rootView.findViewById(R.id.license_one);
    occupation_one = (EditText) rootView.findViewById(R.id.occupation_one);

    alcohol_edit = (EditText) rootView.findViewById(R.id.alcohol_edit);
    drug = (CheckBox) rootView.findViewById(R.id.drug_edit);
    phone_use = (CheckBox) rootView.findViewById(R.id.phone_edit);
    seat_belt = (CheckBox) rootView.findViewById(R.id.seat_belt_edit);

    //Vehicle one details
    type_one = (EditText) rootView.findViewById(R.id.type_one);
    registration_number_one = (EditText) rootView.findViewById(R.id.registration_number_one);

    //Vehicle one  Insurance details
    company_one = (EditText) rootView.findViewById(R.id.company_one);
    insurance_type_one = (EditText) rootView.findViewById(R.id.insurance_type_one);
    insurance_phone = (EditText) rootView.findViewById(R.id.insurance_phone);
    policy_period_one = (EditText) rootView.findViewById(R.id.policy_period_one);
    policy_number_one = (EditText) rootView.findViewById(R.id.policy_number_one);
    repair_amount_one = (EditText) rootView.findViewById(R.id.repair_amount_one);

    //Vehicle one  damage details
    vehicle = (EditText) rootView.findViewById(R.id.vehicle_title_edit);
    vehicle_total = (EditText) rootView.findViewById(R.id.vehicle_total_edit);
    infrastructure = (EditText) rootView.findViewById(R.id.infrastructure_edit);
    cost = (EditText) rootView.findViewById(R.id.rescue_cost_edit);

    /**
     * getting values of our view elements
     */
    drug.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {

            if (((CheckBox) v).isChecked()) {

                MainActivity.V2_drug_edit = "Drugs Use";
            } else {
                MainActivity.V2_drug_edit = " No Drug use";
            }
        }
    });

    phone_use.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {

            if (((CheckBox) v).isChecked()) {

                MainActivity.V2_phone_edit = "Was using Phone";
            } else {
                MainActivity.V2_phone_edit = " No phone use";
            }
        }
    });

    seat_belt.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {

            if (((CheckBox) v).isChecked()) {

                MainActivity.V2_seat_belt_edit = "Seat belt not fastened";
            } else {
                MainActivity.V2_seat_belt_edit = "Seat belt fastened";
            }
        }
    });

    male.setChecked(true);
    //   Fatal.setChecked(true);

    male.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
            if (b == true) {
                female.setChecked(false);
                MainActivity.V2_gender = "male";
            }
        }
    });

    female.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
            if (b == true) {
                male.setChecked(false);
                MainActivity.V2_gender = "female";
            }
        }
    });

    cal = Calendar.getInstance();

    day = cal.get(Calendar.DAY_OF_MONTH);

    month = cal.get(Calendar.MONTH);

    year = cal.get(Calendar.YEAR);

    pickDate = (Button) rootView.findViewById(R.id.date_picker);
    pickDate.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            DatePickerDialog datePickerDialog = new DatePickerDialog(getActivity(), datePickerListener, year,
                    month, day);
            datePickerDialog.show();
        }
    });

    List<String> vehicle_category_list = new ArrayList<String>();
    vehicle_category_list.add("Private");
    vehicle_category_list.add("Commercial");
    vehicle_category_list.add("Government");
    vehicle_category_list.add("Emergency");
    vehicle_category_list.add("Passenger Service Vehicles");

    vehicle_category.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
            selectedSpinner = i;
        }

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

        }
    });

    vehicle_type.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent intent = new Intent(getActivity(), VehicleType.class);
            intent.putExtra("category", selectedSpinner + "");
            startActivity(intent);
        }
    });

    ArrayAdapter<String> atc_adapter = new ArrayAdapter<String>(getActivity(),
            android.R.layout.simple_spinner_item, vehicle_category_list);
    atc_adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    vehicle_category.setAdapter(atc_adapter);

    return rootView;
}

From source file:com.xperia64.timidityae.TrackFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    reset();/*  w  w w  . java  2s .  co m*/

    fileList = new ArrayAdapter<String>(getActivity(), R.layout.row);
    for (int i = 0; i < JNIHandler.MAX_CHANNELS; i++) {
        fileList.add(String.format(getActivity().getResources().getString(R.string.trk_form),
                (getActivity().getResources()
                        .getString(JNIHandler.drums.get(i) ? R.string.trk_drum : R.string.trk_inst2)),
                (i + 1), JNIHandler.drums.get(i) ? 0 : localInst.get(i) + 1, localVol.get(i)));
    }
    channelList.setAdapter(fileList);
    channelList.setOnItemClickListener(new OnItemClickListener() {

        @SuppressLint("InflateParams")
        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, final int arg2, long arg3) {
            AlertDialog.Builder b = new AlertDialog.Builder(getActivity());
            View v = getActivity().getLayoutInflater().inflate(R.layout.track_dialog, null);
            final Spinner instSpin = (Spinner) v.findViewById(R.id.instSpin);
            instSpin.setClickable(JNIHandler.custInst.get(arg2) && !JNIHandler.drums.get(arg2));
            instSpin.setOnLongClickListener(null);
            instSpin.setEnabled(JNIHandler.custInst.get(arg2) && !JNIHandler.drums.get(arg2));
            List<String> arrayAdapter = new ArrayList<String>();
            final int offset = (!JNIHandler.drums.get(arg2)) ? 0 : 34;
            if (!JNIHandler.drums.get(arg2)) {
                for (String inst : getActivity().getResources().getStringArray(R.array.midi_instruments))
                    arrayAdapter.add(inst);
            } else {
                for (String inst : getActivity().getResources().getStringArray(R.array.midi_drums))
                    arrayAdapter.add(inst);
            }
            ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(getActivity(),
                    android.R.layout.simple_spinner_item, arrayAdapter);
            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_item);
            } else {
                dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
            }

            dataAdapter.setNotifyOnChange(false);
            if (!JNIHandler.drums.get(arg2)) {
                instSpin.setAdapter(dataAdapter);
                instSpin.setSelection(localInst.get(arg2) - offset);
            }
            final EditText txtVol = (EditText) v.findViewById(R.id.txtVol);
            txtVol.setText(Integer.toString(localVol.get(arg2)));
            txtVol.setClickable(JNIHandler.custVol.get(arg2));
            txtVol.setEnabled(JNIHandler.custVol.get(arg2));

            final SeekBar volSeek = (SeekBar) v.findViewById(R.id.volSeek);
            volSeek.setClickable(JNIHandler.custVol.get(arg2));
            volSeek.setEnabled(JNIHandler.custVol.get(arg2));
            volSeek.setMax(127);
            volSeek.setProgress(localVol.get(arg2));
            volSeek.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {

                @Override
                public void onProgressChanged(SeekBar arg0, int arg1, boolean arg2) {
                    if (arg2 && !fromUser) {
                        fromUser = true;
                        txtVol.setText(Integer.toString(arg0.getProgress()));
                    } else {
                        fromUser = false;
                    }
                }

                @Override
                public void onStartTrackingTouch(SeekBar arg0) {
                }

                @Override
                public void onStopTrackingTouch(SeekBar arg0) {
                }

            });

            txtVol.addTextChangedListener(new TextWatcher() {
                public void afterTextChanged(Editable s) {
                    if (!fromUser) {
                        if (s.length() > 0) {
                            int numm = Integer.parseInt(s.toString());
                            if (numm > 127) {
                                fromUser = true;
                                numm = 127;
                            }
                            if (numm < 0) {
                                fromUser = true;
                                numm = 0;
                            }
                            if (fromUser) {
                                txtVol.setText(Integer.toString(numm));
                            }
                            fromUser = true;
                            volSeek.setProgress(numm);
                            fromUser = false;
                        }
                    } else {
                        fromUser = false;
                    }
                }

                public void beforeTextChanged(CharSequence s, int start, int count, int after) {
                }

                public void onTextChanged(CharSequence s, int start, int before, int count) {
                }
            });
            final CheckBox inst = (CheckBox) v.findViewById(R.id.defInstr);
            inst.setEnabled(!JNIHandler.drums.get(arg2));
            inst.setChecked(!JNIHandler.custInst.get(arg2));
            inst.setOnCheckedChangeListener(new OnCheckedChangeListener() {

                @Override
                public void onCheckedChanged(CompoundButton arg0, boolean arg1) {

                    instSpin.setClickable(!arg1);
                    instSpin.setEnabled(!arg1);
                }

            });
            final CheckBox vol = (CheckBox) v.findViewById(R.id.defVol);
            vol.setChecked(!JNIHandler.custVol.get(arg2));
            //System.out.println("Def inst: "+(!JNIHandler.custInst.get(arg2)?"true":"false")+" def vol: "+(!JNIHandler.custVol.get(arg2)?"true":"false"));
            vol.setOnCheckedChangeListener(new OnCheckedChangeListener() {

                @Override
                public void onCheckedChanged(CompoundButton arg0, boolean arg1) {

                    volSeek.setClickable(!arg1);
                    volSeek.setEnabled(!arg1);
                    txtVol.setClickable(!arg1);
                    txtVol.setEnabled(!arg1);
                }

            });
            if (Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH)
                v.setBackgroundColor(Globals.theme == 1 ? Color.WHITE : Color.BLACK);
            b.setView(v);
            b.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {

                    JNIHandler.custInst.set(arg2, !inst.isChecked());
                    JNIHandler.custVol.set(arg2, !vol.isChecked());
                    JNIHandler.setChannelVolumeTimidity(arg2 | (JNIHandler.custVol.get(arg2) ? 0x800 : 0x8000),
                            volSeek.getProgress());
                    JNIHandler.setChannelTimidity(arg2 | (JNIHandler.custInst.get(arg2) ? 0x800 : 0x8000),
                            instSpin.getSelectedItemPosition());
                    if (!JNIHandler.paused && Globals.isPlaying == 0)
                        JNIHandler.seekTo(JNIHandler.currTime);
                    //bigCounter=12;
                    updateList();
                }
            });

            b.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                }
            });
            b.setTitle(String.format((getActivity().getResources().getString(R.string.trk_form2)), (arg2 + 1)));
            ddd = b.create();
            ddd.show();
        }

    });
}

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

/**
 * Setup the dropdown spinner that allows the user to select the gender of the pet.
 *///from   w w  w  .ja  v  a  2s  .c o  m
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 genderSpinnerAdapter = ArrayAdapter.createFromResource(this, R.array.array_gender_options,
            android.R.layout.simple_spinner_item);

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

    // Apply the adapter to the spinner
    mGenderSpinner.setAdapter(genderSpinnerAdapter);

    // Set the integer mSelected to the constant values
    mGenderSpinner.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.gender_male))) {
                    mGender = PetsEntry.GENDER_MALE; // Male
                } else if (selection.equals(getString(R.string.gender_female))) {
                    mGender = PetsEntry.GENDER_FEMALE; // Female
                } else {
                    mGender = PetsEntry.GENDER_UNKNWON; // Unknown
                }
            }
        }

        // Because AdapterView is an abstract class, onNothingSelected must be defined
        @Override
        public void onNothingSelected(AdapterView<?> parent) {
            mGender = 0; // Unknown
        }
    });
}

From source file:com.github.jvanhie.discogsscrobbler.SearchActivity.java

@Override
public boolean onCreateOptionsMenu(final Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.discogs_search, menu);
    //configure search box
    final MenuItem search = menu.findItem(R.id.search_field);
    mSearchView = (SearchView) search.getActionView();
    mSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override/*from   w  w w .  jav  a  2s .co  m*/
        public boolean onQueryTextSubmit(String s) {
            menu.findItem(R.id.search_field).collapseActionView();
            mLastSearch = s;
            //pass query to search fragment
            if (mSearchType > 0) {
                mSearchFragment.search(s, mSearchTypes[mSearchType]);
            } else {
                mSearchFragment.search(s);
            }
            return false;
        }

        @Override
        public boolean onQueryTextChange(String s) {
            return false;
        }
    });
    mSearchView.setOnSearchClickListener(new SearchView.OnClickListener() {
        @Override
        public void onClick(View view) {
            //restore last search
            if (mLastSearch != null) {
                mSearchView.setQuery(mLastSearch, false);
            }
        }
    });
    if (mSearchType > 0) {
        mSearchView.setQueryHint("Search Discogs (" + mSearchTypes[mSearchType] + ")");
    } else {
        mSearchView.setQueryHint("Search Discogs");
    }
    //config filter spinner
    final MenuItem filter = menu.findItem(R.id.search_filter);
    Spinner s = (Spinner) filter.getActionView(); // find the spinner
    ArrayAdapter mSpinnerAdapter = ArrayAdapter.createFromResource(getSupportActionBar().getThemedContext(),
            R.array.search_filter_items, android.R.layout.simple_spinner_dropdown_item); //  create the adapter from a StringArray
    mSpinnerAdapter.setDropDownViewResource(R.layout.spinner_dropdown_item);
    s.setAdapter(mSpinnerAdapter); // set the adapter
    s.setSelection(mSearchType, false);

    s.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
            mSearchType = i;
            PreferenceManager.getDefaultSharedPreferences(SearchActivity.this).edit()
                    .putInt(SEARCH_TYPE, mSearchType).apply();
            if (i > 0) {
                mSearchView.setQueryHint("Search Discogs (" + mSearchTypes[i] + ")");
            } else {
                mSearchView.setQueryHint("Search Discogs");
            }
            filter.collapseActionView();
            search.expandActionView();
        }

        @Override
        public void onNothingSelected(AdapterView<?> adapterView) {
            //filter.collapseActionView();
        }
    });
    //make sure only one actionview is expanded
    MenuItemCompat.setOnActionExpandListener(filter, new MenuItemCompat.OnActionExpandListener() {
        @Override
        public boolean onMenuItemActionExpand(MenuItem menuItem) {
            //collapse search
            search.collapseActionView();
            return true;
        }

        @Override
        public boolean onMenuItemActionCollapse(MenuItem menuItem) {
            return true;
        }
    });
    MenuItemCompat.setOnActionExpandListener(search, new MenuItemCompat.OnActionExpandListener() {
        @Override
        public boolean onMenuItemActionExpand(MenuItem menuItem) {
            //collapse filter
            filter.collapseActionView();
            return true;
        }

        @Override
        public boolean onMenuItemActionCollapse(MenuItem menuItem) {
            return true;
        }
    });

    //only expand when the drawer is closed and initial page load
    if (!((DrawerLayout) findViewById(R.id.search_drawer_layout)).isDrawerOpen(findViewById(R.id.search_drawer))
            && !mDetailVisible) {
        search.expandActionView();
    }

    if (mSelected > 0) {

        inflater.inflate(R.menu.release_detail_search, menu);
        if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean("enable_lastfm", true)) {
            inflater.inflate(R.menu.release_detail_scrobble, menu);
        }
    }

    return true;
}

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

private void inflateGenderSpinner() {
    final ArrayList<String> genderNames = filterListObject(clientstemplate.getGenderOptions());
    ArrayAdapter<String> genderAdapter = new ArrayAdapter<String>(getActivity(),
            android.R.layout.simple_spinner_item, genderNames);
    genderAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spGender.setAdapter(genderAdapter);//  w  w  w  . j av a  2  s. c  om
    spGender.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
            genderId = clientstemplate.getGenderOptions().get(i).getId();
            Log.d("genderId " + genderNames.get(i), String.valueOf(genderId));
            if (genderId != -1) {

            } else {
                Toast.makeText(getActivity(), getString(R.string.error_select_office), Toast.LENGTH_SHORT)
                        .show();
            }
        }

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

        }
    });

}

From source file:com.money.manager.ex.fragment.SearchFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if (container == null)
        return null;
    //create view
    View view = (LinearLayout) inflater.inflate(R.layout.search_activity, container, false);
    //create listener amount
    OnClickListener onClickAmount = new OnClickListener() {

        @Override// w  w w .ja v a 2  s.  c o m
        public void onClick(View v) {
            double amount = 0;
            if (v.getTag() != null && v.getTag() instanceof Double) {
                amount = (Double) ((TextView) v).getTag();
            }
            InputAmountDialog dialog = InputAmountDialog.getInstance(v.getId(), amount);
            dialog.show(getSherlockActivity().getSupportFragmentManager(), dialog.getClass().getSimpleName());
        }
    };
    //To Amount
    txtToAmount = (TextView) view.findViewById(R.id.textViewFromAmount);
    txtToAmount.setOnClickListener(onClickAmount);
    //From Amount
    txtFromAmount = (TextView) view.findViewById(R.id.textViewToAmount);
    txtFromAmount.setOnClickListener(onClickAmount);

    // accountlist <> to populate the spin
    spinAccount = (Spinner) view.findViewById(R.id.spinnerAccount);
    if (mAccountList == null) {
        mAccountList = new MoneyManagerOpenHelper(getSherlockActivity()).getListAccounts(
                mApplication.getAccountsOpenVisible(), mApplication.getAccountFavoriteVisible());
        mAccountList.add(0, null);
        for (int i = 0; i <= mAccountList.size() - 1; i++) {
            if (mAccountList.get(i) != null) {
                mAccountNameList.add(mAccountList.get(i).getAccountName());
                mAccountIdList.add(mAccountList.get(i).getAccountId());
            } else {
                mAccountNameList.add("");
                mAccountIdList.add(AdapterView.INVALID_POSITION);
            }
        }
    }
    // checkbox
    cbxDeposit = (CheckBox) view.findViewById(R.id.checkBoxDeposit);
    cbxTransfer = (CheckBox) view.findViewById(R.id.checkBoxTransfer);
    cbxWithdrawal = (CheckBox) view.findViewById(R.id.checkBoxWithdrawal);
    // create adapter for spinAccount
    ArrayAdapter<String> adapterAccount = new ArrayAdapter<String>(getSherlockActivity(),
            R.layout.sherlock_spinner_item, mAccountNameList);
    adapterAccount.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinAccount.setAdapter(adapterAccount);
    //Payee
    txtSelectPayee = (TextView) view.findViewById(R.id.textViewSelectPayee);
    txtSelectPayee.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(getSherlockActivity(), PayeeActivity.class);
            intent.setAction(Intent.ACTION_PICK);
            startActivityForResult(intent, REQUEST_PICK_PAYEE);
        }
    });
    //Category
    txtSelectCategory = (TextView) view.findViewById(R.id.textViewSelectCategory);
    txtSelectCategory.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(getSherlockActivity(), CategorySubCategoryExpandableListActivity.class);
            intent.setAction(Intent.ACTION_PICK);
            startActivityForResult(intent, REQUEST_PICK_CATEGORY);
        }
    });
    if (mStatusItems.size() <= 0) {
        // arrays to manage Status
        mStatusItems.add("");
        mStatusValues.add("");
        mStatusItems.addAll(Arrays.asList(getResources().getStringArray(R.array.status_items)));
        mStatusValues.addAll(Arrays.asList(getResources().getStringArray(R.array.status_values)));
    }
    // create adapter for spinnerStatus
    spinStatus = (Spinner) view.findViewById(R.id.spinnerStatus);
    ArrayAdapter<String> adapterStatus = new ArrayAdapter<String>(getSherlockActivity(),
            R.layout.sherlock_spinner_item, mStatusItems);
    adapterStatus.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinStatus.setAdapter(adapterStatus);
    // from date
    txtFromDate = (TextView) view.findViewById(R.id.textViewFromDate);
    txtFromDate.setOnClickListener(new OnDateButtonClickListener(txtFromDate));
    // to date
    txtToDate = (TextView) view.findViewById(R.id.textViewToDate);
    txtToDate.setOnClickListener(new OnDateButtonClickListener(txtToDate));
    // transaction number
    edtTransNumber = (EditText) view.findViewById(R.id.editTextTransNumber);
    // notes
    edtNotes = (EditText) view.findViewById(R.id.editTextNotes);

    return view;
}

From source file:com.nbos.phonebook.sync.authenticator.AuthenticatorActivity.java

/**
 * {@inheritDoc}//w  ww  .  j a va2s. c  om
 */
@Override
public void onCreate(Bundle icicle) {
    Log.i(tag, "onCreate(" + icicle + ")");
    super.onCreate(icicle);
    mAccountManager = AccountManager.get(this);
    Log.i(tag, "loading data from Intent");
    final Intent intent = getIntent();
    mUsername = intent.getStringExtra(PARAM_USERNAME);
    mAuthtokenType = intent.getStringExtra(PARAM_AUTHTOKEN_TYPE);
    mRequestNewAccount = mUsername == null;
    mConfirmCredentials = intent.getBooleanExtra(PARAM_CONFIRMCREDENTIALS, false);

    Log.i(tag, "request new: " + mRequestNewAccount + " ,ConfirmCredentials: " + mConfirmCredentials);
    requestWindowFeature(Window.FEATURE_LEFT_ICON);
    setContentView(R.layout.login_activity);
    getWindow().setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, android.R.drawable.ic_dialog_alert);

    Spinner spinner = (Spinner) findViewById(R.id.spinner);
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.country_code_array,
            android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(adapter);
    spinner.setOnItemSelectedListener(this);
    setSpinnerCountry(spinner);
    mMessage = (TextView) findViewById(R.id.message);
    mUsernameEdit = (EditText) findViewById(R.id.username_edit);
    mPasswordEdit = (EditText) findViewById(R.id.password_edit);
    mPhoneEdit = (EditText) findViewById(R.id.phone_edit);
    getPhoneNumber(getApplicationContext());
    mUsernameEdit.setText(mUsername);
    mMessage.setText(getMessage());
}

From source file:com.h6ah4i.android.example.openslmediaplayer.app.contents.VisualizerFragment.java

private void setupViews() {
    VisualizerStateStore state = getStateStore();
    Context context = getActivity();

    mDuringSetupViews = true;//from   w  ww.j a v  a  2s.  c  om

    mToggleButtonEnableWaveform.setChecked(state.isCaptureWaveformEnabled());
    mToggleButtonEnableFft.setChecked(state.isCaptureFftEnabled());
    mToggleButtonEnablePeak.setChecked(state.isMeasurementPeakEnabled());
    mToggleButtonEnableRms.setChecked(state.isMeasurementRmsEnabled());

    {
        final ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(context,
                R.array.visualizer_scaling_mode_names, android.R.layout.simple_spinner_item);
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        mSpinnerScalingMode.setAdapter(adapter);
    }

    mSpinnerScalingMode.setSelection(state.getScalingMode());

    mDuringSetupViews = false;
}