List of usage examples for android.widget ArrayAdapter setDropDownViewResource
public void setDropDownViewResource(@LayoutRes int resource)
Sets the layout resource to create the drop down views.
From source file:can.yrt.onebusaway.ReportStopProblemFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { // Set the stop name. Bundle args = getArguments();/*from w ww . j a v a2 s .c om*/ final TextView stopName = (TextView) view.findViewById(R.id.stop_name); stopName.setText(MyTextUtils.toTitleCase(args.getString(STOP_NAME))); // // The code spinner // mCodeView = (Spinner) view.findViewById(R.id.report_problem_code); ArrayAdapter<?> adapter = ArrayAdapter.createFromResource(getActivity(), R.array.report_stop_problem_code, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mCodeView.setAdapter(adapter); // Comment mUserComment = (TextView) view.findViewById(R.id.report_problem_comment); if (savedInstanceState != null) { int position = savedInstanceState.getInt(CODE); mCodeView.setSelection(position); CharSequence comment = savedInstanceState.getCharSequence(USER_COMMENT); mUserComment.setText(comment); } }
From source file:com.grokkingandroid.sampleapp.samples.actionbar.actionviews.ActionViewActivity.java
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); getSupportActionBar().setDisplayOptions(0, ActionBar.DISPLAY_SHOW_TITLE); setContentView(R.layout.activity_fragment_container); int resId = R.array.spinner_without_searchview; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO) { resId = R.array.spinner_with_searchview; }/*from ww w . jav a2 s . c o m*/ mSpinnerArray = getResources().getStringArray(resId); ArrayAdapter<CharSequence> spinnerAdapter = ArrayAdapter.createFromResource( getSupportActionBar().getThemedContext(), resId, R.layout.sherlock_spinner_item); spinnerAdapter.setDropDownViewResource(R.layout.sherlock_spinner_dropdown_item); getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); getSupportActionBar().setListNavigationCallbacks(spinnerAdapter, new OnNavigationListener() { @Override public boolean onNavigationItemSelected(int itemPosition, long itemId) { if (itemPosition == mCurrSpinnerPos) { return true; } int pos = itemPosition; if (mSpinnerArray.length == 3) { pos++; } Fragment f = null; switch (pos) { case 0: f = SearchViewFragment.newInstance(); break; case 1: f = PlaceholderActionViewFragment.newInstance(); break; case 2: f = PreExpandedActionViewFragment.newInstance(); break; case 3: f = ExpandableActionViewFragment.newInstance(); break; } getSupportFragmentManager().beginTransaction().replace(R.id.demo_fragment_container, f).commit(); mCurrSpinnerPos = itemPosition; return true; } }); if (icicle != null) { int spinnerPos = icicle.getInt(KEY_SPINNER_POS, 0); mCurrSpinnerPos = spinnerPos; getSupportActionBar().setSelectedNavigationItem(spinnerPos); return; } Fragment fragment = null; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO) { // SearchView only from API level 8 onwards fragment = SearchViewFragment.newInstance(); } else { fragment = PlaceholderActionViewFragment.newInstance(); } getSupportFragmentManager().beginTransaction().add(R.id.demo_fragment_container, fragment).commit(); }
From source file:com.irccloud.android.fragment.AddChannelFragment.java
@Override public void onResume() { int pos = 0;/*from www . jav a 2s . co m*/ super.onResume(); servers = ServersList.getInstance().getServers(); ArrayList<String> servernames = new ArrayList<String>(); for (int i = 0; i < servers.size(); i++) { servernames.add(servers.valueAt(i).getName()); if (servers.valueAt(i).getCid() == defaultCid) pos = i; } ArrayAdapter<String> adapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_spinner_item, android.R.id.text1, servernames.toArray(new String[servernames.size()])); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter); spinner.setSelection(pos); }
From source file:com.gsma.rcs.provisioning.local.ProfileProvisioning.java
@Override public void displayRcsSettings() { if (sLogger.isActivated()) { sLogger.debug("displayRcsSettings"); }//from w w w . j a va 2s . c o m Spinner spinner = (Spinner) mRootView.findViewById(R.id.ImsAuthenticationProcedureForMobile); ArrayAdapter<String> adapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_spinner_item, MOBILE_IMS_AUTHENT); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter); spinner.setSelection(sRcsSettings.getImsAuthenticationProcedureForMobile().toInt()); mHelper.setContactIdEditText(R.id.ImsUsername, RcsSettingsData.USERPROFILE_IMS_USERNAME); mHelper.setStringEditText(R.id.ImsDisplayName, RcsSettingsData.USERPROFILE_IMS_DISPLAY_NAME); mHelper.setStringEditText(R.id.ImsHomeDomain, RcsSettingsData.USERPROFILE_IMS_HOME_DOMAIN); mHelper.setStringEditText(R.id.ImsPrivateId, RcsSettingsData.USERPROFILE_IMS_PRIVATE_ID); mHelper.setStringEditText(R.id.ImsPassword, RcsSettingsData.USERPROFILE_IMS_PASSWORD); mHelper.setStringEditText(R.id.ImsRealm, RcsSettingsData.USERPROFILE_IMS_REALM); mHelper.setStringEditText(R.id.ImsOutboundProxyAddrForMobile, RcsSettingsData.IMS_PROXY_ADDR_MOBILE); mHelper.setIntEditText(R.id.ImsOutboundProxyPortForMobile, RcsSettingsData.IMS_PROXY_PORT_MOBILE); mHelper.setStringEditText(R.id.ImsOutboundProxyAddrForWifi, RcsSettingsData.IMS_PROXY_ADDR_WIFI); mHelper.setIntEditText(R.id.ImsOutboundProxyPortForWifi, RcsSettingsData.IMS_PROXY_PORT_WIFI); mHelper.setUriEditText(R.id.XdmServerAddr, RcsSettingsData.XDM_SERVER); mHelper.setStringEditText(R.id.XdmServerLogin, RcsSettingsData.XDM_LOGIN); mHelper.setStringEditText(R.id.XdmServerPassword, RcsSettingsData.XDM_PASSWORD); mHelper.setUriEditText(R.id.FtHttpServerAddr, RcsSettingsData.FT_HTTP_SERVER); mHelper.setStringEditText(R.id.FtHttpServerLogin, RcsSettingsData.FT_HTTP_LOGIN); mHelper.setStringEditText(R.id.FtHttpServerPassword, RcsSettingsData.FT_HTTP_PASSWORD); mHelper.setUriEditText(R.id.ImConferenceUri, RcsSettingsData.IM_CONF_URI); mHelper.setUriEditText(R.id.EndUserConfReqUri, RcsSettingsData.ENDUSER_CONFIRMATION_URI); mHelper.setStringEditText(R.id.RcsApn, RcsSettingsData.RCS_APN); TextView txt = (TextView) mRootView.findViewById(R.id.release); txt.setText(sRcsSettings.getGsmaRelease().name()); txt = (TextView) mRootView.findViewById(R.id.user_msg_title); String title = sRcsSettings.getProvisioningUserMessageTitle(); if (title != null) { txt.setText(title); } txt = (TextView) mRootView.findViewById(R.id.user_msg_content); String content = sRcsSettings.getProvisioningUserMessageContent(); if (content != null) { txt.setText(content); } }
From source file:com.secbro.qark.customintent.ChooseIntentUseCaseActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_choose_intent_use_case); final Intent customIntent = getIntent().getParcelableExtra(CreateCustomIntentActivity.CUSTOM_INTENT_EXTRA); if (customIntent == null) { throw new IllegalArgumentException("customIntent is null"); }//w ww.j a v a 2 s .c o m //intent usecase spinner usecaseSpinner = (Spinner) findViewById(R.id.intent_use_case_spinner); ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.intent_use_case, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); usecaseSpinner.setAdapter(adapter); //Send intent button sendIntentButton = (Button) findViewById(R.id.activity_choose_intent_use_case_send_button); errorDialog = new AlertDialog.Builder(this).create(); errorDialog.setTitle("Error"); errorDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); sendIntentButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (usecaseSpinner.getSelectedItem() == null) { errorDialog.setMessage("Invalid intent use case"); errorDialog.show(); } else { String useCase = usecaseSpinner.getSelectedItem().toString(); switch (useCase) { case "startActivity": //TODO: Validate data for startActivity is present startActivity(customIntent); break; case "startActivityForResult": //TODO:Validate customIntent startActivityForResult(customIntent, START_ACTIVITY_FOR_RESULT); break; case "startService": //TODO:Validate customIntent startService(customIntent); break; case "bindService": //TODO: break; case "sendBroadcast": //TODO:Validate customIntent sendBroadcast(customIntent); break; case "sendOrderedBroadcast": //TODO: //sendOrderedBroadcast(customIntent); break; case "sendStickyBroadcast": //TODO:Validate customIntent sendStickyBroadcast(customIntent); break; default: break; } } } }); }
From source file:de.quist.app.maps.example.LayersDemoActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.layers_demo); Spinner spinner = (Spinner) findViewById(R.id.layers_spinner); ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.layers_array, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter);/* w w w. j av a 2 s .c o m*/ spinner.setOnItemSelectedListener(this); mTrafficCheckbox = (CheckBox) findViewById(R.id.traffic); mMyLocationCheckbox = (CheckBox) findViewById(R.id.my_location); mBuildingsCheckbox = (CheckBox) findViewById(R.id.buildings); mIndoorCheckbox = (CheckBox) findViewById(R.id.indoor); SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager() .findFragmentById(R.id.map); mapFragment.getMapAsync(this); }
From source file:com.example.travelclaims.NewExpenseActivity.java
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.addnewexpense); DateView = (EditText) findViewById(R.id.editDate); final Spinner categoryspinner = (Spinner) findViewById(R.id.categoryspinner); ArrayAdapter<CharSequence> categoryadapter = ArrayAdapter.createFromResource(this, R.array.category_array, android.R.layout.simple_spinner_item); categoryadapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); categoryspinner.setAdapter(categoryadapter); final Spinner currencyspinner = (Spinner) findViewById(R.id.currencyspinner); ArrayAdapter<CharSequence> currencyadapter = ArrayAdapter.createFromResource(this, R.array.currency_array, android.R.layout.simple_spinner_item); currencyadapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); currencyspinner.setAdapter(currencyadapter); currencyspinner.setOnItemSelectedListener(new OnItemSelectedListener() { @Override//from ww w .ja v a 2 s .com public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) { currency = currencyspinner.getSelectedItem().toString(); } @Override public void onNothingSelected(AdapterView<?> arg0) { // TODO Auto-generated method stub } }); categoryspinner.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) { category = categoryspinner.getSelectedItem().toString(); } @Override public void onNothingSelected(AdapterView<?> arg0) { // TODO Auto-generated method stub } }); set_on_click(); }
From source file:com.example.administrator.mynews.view.AdMobBannerSizesFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_admob_banner_sizes, container, false); mSizesSpinner = (Spinner) rootView.findViewById(R.id.bannersizes_spn_size); mLoadButton = (Button) rootView.findViewById(R.id.bannersizes_btn_loadad); mAdFrameLayout = (FrameLayout) rootView.findViewById(R.id.bannersizes_fl_adframe); String[] sizesArray;/*from ww w .j a va 2 s . co m*/ // It is a Mobile Ads SDK policy that only the banner, large banner, and smart banner ad // sizes are shown on phones, and that the full banner, leaderboard, and medium rectangle // sizes are reserved for use on tablets. The conditional below checks the screen size // and retrieves the correct list. int screenSize = getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK; if ((screenSize == Configuration.SCREENLAYOUT_SIZE_LARGE) || (screenSize == Configuration.SCREENLAYOUT_SIZE_XLARGE)) { sizesArray = getResources().getStringArray(R.array.bannersizes_largesizes); } else { sizesArray = getResources().getStringArray(R.array.bannersizes_smallsizes); } ArrayAdapter<CharSequence> adapter = new ArrayAdapter<CharSequence>(rootView.getContext(), android.R.layout.simple_spinner_dropdown_item, sizesArray); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mSizesSpinner.setAdapter(adapter); mLoadButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (mAdView != null) { mAdFrameLayout.removeView(mAdView); mAdView.destroy(); } mAdView = new AdView(getActivity()); mAdView.setAdUnitId(getString(R.string.admob_banner_ad_unit_id)); mAdFrameLayout.addView(mAdView); switch (mSizesSpinner.getSelectedItemPosition()) { case 0: mAdView.setAdSize(AdSize.BANNER); break; case 1: mAdView.setAdSize(AdSize.LARGE_BANNER); break; case 2: mAdView.setAdSize(AdSize.SMART_BANNER); break; case 3: mAdView.setAdSize(AdSize.FULL_BANNER); break; case 4: mAdView.setAdSize(AdSize.MEDIUM_RECTANGLE); break; case 5: mAdView.setAdSize(AdSize.LEADERBOARD); break; } mAdView.loadAd(new AdRequest.Builder().build()); } }); return rootView; }
From source file:com.explovia.mapdemo.LayersDemoActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.layers_demo); Spinner spinner = (Spinner) findViewById(R.id.layers_spinner); ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.layers_array, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter);/* w ww . java 2 s . c o m*/ spinner.setOnItemSelectedListener(this); mTrafficCheckbox = (CheckBox) findViewById(R.id.traffic); mMyLocationCheckbox = (CheckBox) findViewById(R.id.my_location); mBuildingsCheckbox = (CheckBox) findViewById(R.id.buildings); mIndoorCheckbox = (CheckBox) findViewById(R.id.indoor); setUpMapIfNeeded(); }
From source file:com.androzic.waypoint.WaypointProject.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.act_waypoint_project, container); Activity activity = getActivity();//from ww w.j a v a2s .co m Androzic application = Androzic.getApplication(); waypoints = application.getWaypoints(); ((TextView) view.findViewById(R.id.name_text)).setText("WPT" + waypoints.size()); Collections.sort(waypoints, new Comparator<Waypoint>() { @Override public int compare(Waypoint o1, Waypoint o2) { return (o1.name.compareToIgnoreCase(o2.name)); } }); String[] items = new String[waypoints.size() + 1]; items[0] = getString(R.string.currentloc); int i = 1; for (Waypoint wpt : waypoints) { items[i] = wpt.name; i++; } ArrayAdapter<String> adapter = new ArrayAdapter<String>(activity, android.R.layout.simple_spinner_item, items); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); ((Spinner) view.findViewById(R.id.source_spinner)).setAdapter(adapter); items = new String[2]; items[0] = StringFormatter.distanceAbbr; items[1] = StringFormatter.distanceShortAbbr; adapter = new ArrayAdapter<String>(activity, android.R.layout.simple_spinner_item, items); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); ((Spinner) view.findViewById(R.id.distance_spinner)).setAdapter(adapter); items = getResources().getStringArray(R.array.angle_types); adapter = new ArrayAdapter<String>(activity, android.R.layout.simple_spinner_item, items); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); ((TextView) view.findViewById(R.id.bearing_abbr)).setText(StringFormatter.angleAbbr); ((Spinner) view.findViewById(R.id.bearing_spinner)).setAdapter(adapter); ((Spinner) view.findViewById(R.id.bearing_spinner)).setSelection(application.angleMagnetic ? 1 : 0); ((Button) view.findViewById(R.id.done_button)).setOnClickListener(doneOnClickListener); ((Button) view.findViewById(R.id.cancel_button)).setOnClickListener(new OnClickListener() { public void onClick(View v) { dismiss(); } }); return view; }