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:net.alchemiestick.katana.winehqappdb.filter_dialog.java

private void setupSpinner(int spId, int arrayId, String cur, AdapterView.OnItemSelectedListener listener) {
    Spinner sp = (Spinner) findViewById(spId);
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(cx, arrayId,
            android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    sp.setAdapter(adapter);/*from w w w .j  av  a  2s.c  o  m*/
    int pos = adapter.getPosition(cur);
    sp.setSelection(pos);
    sp.setOnItemSelectedListener(listener);
}

From source file:com.gh4a.activities.ExploreActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    setTheme(Gh4Application.THEME);/* ww  w.j a v  a 2s  . co m*/
    super.onCreate(savedInstanceState);

    if (!isOnline()) {
        setErrorView();
        return;
    }

    setContentView(R.layout.explore);

    mActionBar = getSupportActionBar();
    mActionBar.setDisplayShowTitleEnabled(false);
    mActionBar.setDisplayHomeAsUpEnabled(true);

    ArrayAdapter<CharSequence> list = ArrayAdapter.createFromResource(mActionBar.getThemedContext(),
            R.array.explore_item, R.layout.sherlock_spinner_item);
    list.setDropDownViewResource(R.layout.row_simple);

    mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
    mActionBar.setListNavigationCallbacks(list, this);

    setPageIndicator(mActionBar.getSelectedNavigationIndex());
}

From source file:com.example.android.fragments._3_IncidentDescription.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    ll = (RelativeLayout) inflater.inflate(R.layout.incidentdescription, container, false);
    sendbutton = ((Button) ll.findViewById(R.id.descr_finished_button));
    sendbutton.setOnClickListener(this);
    locdescrp = ((TextView) ll.findViewById(R.id.detailed_location_description));
    locdescrp.setOnClickListener(this);
    damagdescrinfo = ((TextView) ll.findViewById(R.id.damage_description_information));
    damagdescrinfo.setOnClickListener(this);
    Spinner spinner = ((Spinner) ll.findViewById(R.id.facilities_spinner));
    //spinner.setOnClickListener(this);
    // Create an ArrayAdapter using the string array and a default spinner layout
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(ll.getContext(), R.array.facilities,
            android.R.layout.simple_spinner_item);
    // Specify the layout to use when the list of choices appears
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    // Apply the adapter to the spinner
    spinner.setAdapter(adapter);// www . j  a v  a2  s  .  com

    // Inflate the layout for this fragment
    return ll;
}

From source file:com.publisnet.leydeinfogobierno.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    ad = new AdView(this, AdSize.BANNER, "a152e6f4cb5b418");

    LinearLayout layout = (LinearLayout) findViewById(R.id.admob);
    // Iniciar una solicitud genrica para cargarla con un anuncio
    ad.loadAd(new AdRequest());
    // Aadirle la adView
    layout.addView(ad);//from   www  .ja  v  a 2s  .co  m
    actionBar = getSupportActionBar();
    actionBar.setDisplayShowTitleEnabled(true);
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
    actionBar.setTitle(R.string.app_tittle);

    final String[] dropdownValues = getResources().getStringArray(R.array.string_array_name);

    // Specify a SpinnerAdapter to populate the dropdown list.
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(actionBar.getThemedContext(),
            android.R.layout.simple_spinner_item, android.R.id.text1, dropdownValues);

    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

    // Set up the dropdown list navigation in the action bar.
    actionBar.setListNavigationCallbacks(adapter, this);
}

From source file:com.nomprenom2.view.NameParamsFragment.java

/**
 * Constructs fragment view, sets fields and click listener
 * @param inflater/*w w  w  . j a v  a  2s .c om*/
 * @param container
 * @param savedInstanceState
 * @return
 */
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.fragment_name_params, container, false);
    // TODO: Move non-ui data to presenter layer
    String[] sex_sel = getResources().getStringArray(R.array.sex_sels);
    ArrayAdapter<String> adapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_spinner_item,
            sex_sel);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    sex_spinner = (Spinner) v.findViewById(R.id.sex_spinner);
    sex_spinner.setAdapter(new NothingSelectedSpinnerAdapter(adapter,
            R.layout.contact_spinner_row_nothing_selected, getActivity()));
    // zodiac spinner
    String[] zod_sel = getResources().getStringArray(R.array.zod_sels);
    ArrayAdapter<String> zod_adapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_spinner_item,
            zod_sel);
    zod_adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    zod_spinner = (Spinner) v.findViewById(R.id.zodiac_spinner);
    zod_spinner.setAdapter(new NothingSelectedSpinnerAdapter(zod_adapter,
            R.layout.zodiac_spinner_row_nothing_selected, getActivity()));

    regions = new HashSet<>();
    frag_list = new ArrayList<>();
    if (savedInstanceState != null)
        setGroupList();

    Button regs = (Button) v.findViewById(R.id.select_region_button);
    regs.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            NameParamsFragment.this.selectRegion();
        }
    });
    return v;
}

From source file:com.normalexception.app.rx8club.dialog.MoveThreadDialog.java

/**
 * Constructor for method that is used to move a thread from one
 * forum to another   /*from  w w  w .  ja va 2 s  .  c o m*/
 * @param ctx         The source context/activity   
 * @param securitytoken   The security token for the session
 * @param src_thread   The source thread
 * @param tTitle      The new thread title
 * @param options      The options from the move dialog
 */
public MoveThreadDialog(final Fragment ctx, final String securitytoken, final String src_thread, String tTitle,
        final Map<String, Integer> options) {
    builder = new AlertDialog.Builder(ctx.getActivity());

    // Set up the input
    final TextView lbl_title = new TextView(ctx.getActivity());
    final EditText title = new EditText(ctx.getActivity());
    final TextView lbl_dest = new TextView(ctx.getActivity());
    final Spinner destination = new Spinner(ctx.getActivity());

    // Lets make sure the user didn't accidentally click this
    DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            switch (which) {
            case DialogInterface.BUTTON_POSITIVE:
                newTitle = title.getText().toString();
                String selectText = destination.getSelectedItem().toString();
                selection = options.get(selectText);

                AsyncTask<Void, String, Void> updaterTask = new AsyncTask<Void, String, Void>() {
                    @Override
                    protected Void doInBackground(Void... params) {
                        try {
                            HtmlFormUtils.adminMoveThread(securitytoken, src_thread, newTitle,
                                    Integer.toString(selection));
                        } catch (Exception e) {
                            Log.e(TAG, "Error Submitting Form For Move", e);
                        }
                        return null;
                    }

                    @Override
                    protected void onPostExecute(Void result) {
                        ctx.getFragmentManager().popBackStack();
                        CategoryFragment cFrag = (CategoryFragment) ((ThreadFragment) ctx).getParentCategory();
                        cFrag.refreshView();
                    }
                };
                updaterTask.execute();
                break;
            case DialogInterface.BUTTON_NEGATIVE:
                break;
            }
        }
    };

    // Specify the type of input expected
    lbl_title.setText("Thread Title");
    lbl_title.setTextColor(Color.WHITE);
    lbl_dest.setText("Desination");
    lbl_dest.setTextColor(Color.WHITE);
    title.setInputType(InputType.TYPE_CLASS_TEXT);
    title.setText(tTitle);

    List<String> values = new ArrayList<String>();
    values.addAll(options.keySet());

    ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(ctx.getActivity(),
            android.R.layout.simple_spinner_item, values);
    dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    destination.setAdapter(dataAdapter);

    LinearLayout ll = new LinearLayout(ctx.getActivity());
    ll.setOrientation(LinearLayout.VERTICAL);
    ll.addView(lbl_title);
    ll.addView(title);
    ll.addView(lbl_dest);
    ll.addView(destination);

    builder.setView(ll);

    builder.setTitle(R.string.dialogMoveThread).setPositiveButton(R.string.Move, dialogClickListener)
            .setNegativeButton(R.string.cancel, dialogClickListener);
}

From source file:com.example.hana.rentcostumes.RegisterActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_register);
    setupView();/*from   ww  w .  j a v a  2  s.  c o  m*/
    inputGender.setOnItemSelectedListener(this);
    ArrayAdapter arrayAdapter = new ArrayAdapter(this, android.R.layout.simple_spinner_item, list_gender);
    arrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    inputGender.setAdapter(arrayAdapter);

    firebaseAuth = FirebaseAuth.getInstance();

    mAuthListener = new FirebaseAuth.AuthStateListener() {
        @Override
        public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
            FirebaseUser user = firebaseAuth.getCurrentUser();
            if (user != null) {
                //Toast.makeText(RegisterActivity.this, "mmmmmmmmmmmmmmmmmmm", Toast.LENGTH_SHORT).show();
                // User is signed in
                Log.d(TAG, "onAuthStateChanged:signed_in:" + user.getUid());
            } else {
                // User is signed out
                Log.d(TAG, "onAuthStateChanged:signed_out");
            }
            // ...
        }
    };

    //        ActionBar actionBar = getActionBar();
    //        if(actionBar!=null)
    //            actionBar.setDisplayHomeAsUpEnabled(false);

    btnRegister.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            signup();
        }
    });
}

From source file:com.gsma.rcs.provisioning.local.ServiceProvisioning.java

@Override
public void displayRcsSettings() {
    mHelper.setLongEditText(R.id.MaxPhotoIconSize, RcsSettingsData.MAX_PHOTO_ICON_SIZE);
    mHelper.setIntEditText(R.id.MaxFreetextLength, RcsSettingsData.MAX_FREETXT_LENGTH);
    mHelper.setIntEditText(R.id.MaxChatParticipants, RcsSettingsData.MAX_CHAT_PARTICIPANTS);
    mHelper.setIntEditText(R.id.MaxChatMessageLength, RcsSettingsData.MAX_CHAT_MSG_LENGTH);
    mHelper.setIntEditText(R.id.MaxGroupChatMessageLength, RcsSettingsData.MAX_GROUPCHAT_MSG_LENGTH);
    mHelper.setLongEditText(R.id.ChatIdleDuration, RcsSettingsData.CHAT_IDLE_DURATION);
    mHelper.setLongEditText(R.id.MaxFileTransferSize, RcsSettingsData.MAX_FILE_TRANSFER_SIZE);
    mHelper.setLongEditText(R.id.WarnFileTransferSize, RcsSettingsData.WARN_FILE_TRANSFER_SIZE);
    mHelper.setLongEditText(R.id.MaxImageShareSize, RcsSettingsData.MAX_IMAGE_SHARE_SIZE);
    mHelper.setLongEditText(R.id.MaxVideoShareDuration, RcsSettingsData.MAX_VIDEO_SHARE_DURATION);
    mHelper.setLongEditText(R.id.MaxAudioMessageDuration, RcsSettingsData.MAX_AUDIO_MESSAGE_DURATION);
    mHelper.setIntEditText(R.id.MaxChatSessions, RcsSettingsData.MAX_CHAT_SESSIONS);
    mHelper.setIntEditText(R.id.MaxFileTransferSessions, RcsSettingsData.MAX_FILE_TRANSFER_SESSIONS);
    mHelper.setIntEditText(R.id.MaxConcurrentOutgoingFileTransferSessions,
            RcsSettingsData.MAX_CONCURRENT_OUTGOING_FILE_TRANSFERS);
    mHelper.setIntEditText(R.id.MaxIpCallSessions, RcsSettingsData.MAX_IP_CALL_SESSIONS);
    mHelper.setIntEditText(R.id.MaxChatLogEntries, RcsSettingsData.MAX_CHAT_LOG_ENTRIES);
    mHelper.setIntEditText(R.id.MaxRichcallLogEntries, RcsSettingsData.MAX_RICHCALL_LOG_ENTRIES);
    mHelper.setIntEditText(R.id.MaxIpcallLogEntries, RcsSettingsData.MAX_IPCALL_LOG_ENTRIES);
    mHelper.setStringEditText(R.id.DirectoryPathPhotos, RcsSettingsData.DIRECTORY_PATH_PHOTOS);
    mHelper.setStringEditText(R.id.DirectoryPathVideos, RcsSettingsData.DIRECTORY_PATH_VIDEOS);
    mHelper.setStringEditText(R.id.DirectoryPathAudios, RcsSettingsData.DIRECTORY_PATH_AUDIOS);
    mHelper.setStringEditText(R.id.DirectoryPathFiles, RcsSettingsData.DIRECTORY_PATH_FILES);
    mHelper.setStringEditText(R.id.DirectoryPathFileIcons, RcsSettingsData.DIRECTORY_PATH_FILEICONS);
    mHelper.setIntEditText(R.id.MaxGeolocLabelLength, RcsSettingsData.MAX_GEOLOC_LABEL_LENGTH);
    mHelper.setLongEditText(R.id.GeolocExpirationTime, RcsSettingsData.GEOLOC_EXPIRATION_TIME);
    mHelper.setLongEditText(R.id.CallComposerIdleDuration, RcsSettingsData.CALL_COMPOSER_INACTIVITY_TIMEOUT);
    Spinner spinner = (Spinner) mRootView.findViewById(R.id.ImSessionStart);
    ArrayAdapter<String> adapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_spinner_item,
            IM_SESSION_START_MODES);/*from w  w  w .  ja va2s .com*/
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(adapter);
    setSpinnerParameter(spinner, RcsSettingsData.IM_SESSION_START, true, IM_SESSION_START_MODES);

    mHelper.setBoolCheckBox(R.id.SmsFallbackService, RcsSettingsData.SMS_FALLBACK_SERVICE);
    mHelper.setBoolCheckBox(R.id.StoreForwardServiceWarning, RcsSettingsData.WARN_SF_SERVICE);
    mHelper.setBoolCheckBox(R.id.AutoAcceptFileTransfer, RcsSettingsData.AUTO_ACCEPT_FILE_TRANSFER);
    mHelper.setBoolCheckBox(R.id.AutoAcceptFileTransferInRoaming, RcsSettingsData.AUTO_ACCEPT_FT_IN_ROAMING);
    mHelper.setBoolCheckBox(R.id.AutoAcceptFileTransferChangeable, RcsSettingsData.AUTO_ACCEPT_FT_CHANGEABLE);
    mHelper.setBoolCheckBox(R.id.AutoAcceptChat, RcsSettingsData.AUTO_ACCEPT_CHAT);
    mHelper.setBoolCheckBox(R.id.AutoAcceptGroupChat, RcsSettingsData.AUTO_ACCEPT_GROUP_CHAT);
    mHelper.setBoolCheckBox(R.id.EnrichCalling, RcsSettingsData.ENRICH_CALLING_SERVICE);
}

From source file:br.com.frs.foodrestrictions.FoodMessages.java

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

    restrictList = foodIconList.getFoodRestrictionList(true);

    llAllergic = (LinearLayout) v.findViewById(R.id.llAllergic);
    llDontEat = (LinearLayout) v.findViewById(R.id.llDontEat);

    allergicText = (TextView) v.findViewById(R.id.messages_allergic_text);
    dontEatText = (TextView) v.findViewById(R.id.messages_dont_eat_text);

    Spinner spinner = (Spinner) v.findViewById(R.id.spinner_language);
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(v.getContext(),
            R.array.languages_array, android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(adapter);//from   ww  w  . j a  v  a  2 s.c o m
    spinner.setOnItemSelectedListener(this);

    return v;
}

From source file:com.teddoll.movies.MainActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu_main, menu);
    final MenuItem sort = menu.findItem(R.id.menu_list_select);
    Spinner spinner = (Spinner) MenuItemCompat.getActionView(sort);
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.sort_array,
            R.layout.item_action_bar_spinner);
    adapter.setDropDownViewResource(R.layout.item_action_bar_spinner_item);
    spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override//  w ww  . j  a  v a  2s . co m
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            sort(position);
        }

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

        }
    });
    spinner.setAdapter(adapter);
    spinner.setSelection(this.sort.ordinal());
    return true;
}