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:com.wishlist.Wishlist.java
public void setPlacesSpinnerAdapter(int spinner_array) { ArrayAdapter<CharSequence> location_adapter = ArrayAdapter.createFromResource(this, spinner_array, android.R.layout.simple_spinner_item); location_adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mPlacesListSpinner.setAdapter(location_adapter); mPlacesListSpinner.invalidate();/*from w w w . j av a 2 s .c om*/ }
From source file:com.mifos.mifosxdroid.online.grouploanaccount.GroupLoanAccountFragment.java
@Override public void showAllLoans(List<LoanProducts> loans) { /* Activity is null - Fragment has been detached; no need to do anything. */ if (getActivity() == null) return;// ww w .ja va2s . c o m final List<String> loansList = new ArrayList<String>(); for (LoanProducts loansname : loans) { loansList.add(loansname.getName()); loansNameIdHashMap.put(loansname.getName(), loansname.getId()); } ArrayAdapter<String> loansAdapter = new ArrayAdapter<>(getActivity(), layout.simple_spinner_item, loansList); loansAdapter.setDropDownViewResource(layout.simple_spinner_dropdown_item); sp_lproduct.setAdapter(loansAdapter); sp_lproduct.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { productId = loansNameIdHashMap.get(loansList.get(i)); Log.d("productId " + loansList.get(i), String.valueOf(productId)); if (productId != -1) { inflateLoanPurposeSpinner(); } else { Toast.makeText(getActivity(), getString(R.string.error_select_loan), Toast.LENGTH_SHORT).show(); } } @Override public void onNothingSelected(AdapterView<?> parent) { } }); }
From source file:com.owo.android.mtPlease.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Set up the action bar final ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); actionBar.setDisplayShowTitleEnabled(false); actionBar.setHomeButtonEnabled(true); actionBar.setDisplayHomeAsUpEnabled(true); // setting for the sidedrawer // set the content view setBehindContentView(R.layout.drawer_search); getSlidingMenu().setFadeEnabled(true); getSlidingMenu().setShadowWidthRes(R.dimen.shadow_width); getSlidingMenu().setShadowDrawable(R.drawable.shadow); getSlidingMenu().setFadeDegree(0.90f); searchDrawerCloseButton = (ImageButton) findViewById(R.id.button_search_drawer_close); searchDrawerCloseButton.setOnClickListener(new OnClickListener() { @Override/*from ww w .j ava 2 s .c o m*/ public void onClick(View v) { // TODO Auto-generated method stub getSlidingMenu().showContent(); } }); // Create the adapter that will return a fragment for each of the three // primary sections of the activity. mSectionsPagerAdapter = new SectionsPagerAdapter(getFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mSectionsPagerAdapter); // When swiping between different sections, select the corresponding // tab. We can also use ActionBar.Tab#select() to do this if we have // a reference to the Tab. mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { actionBar.setSelectedNavigationItem(position); } }); // mViewPager.setOffscreenPageLimit(3); // For each of the sections in the app, add a tab to the action bar. for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) { // Create a tab with text corresponding to the page title defined by // the adapter. Also specify this Activity object, which implements // the TabListener interface, as the callback (listener) for when // this tab is selected. actionBar .addTab(actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this)); } locationSelectSpinner = (Spinner) findViewById(R.id.spinner_location); ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.location_array, R.layout.spinner_text); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); locationSelectSpinner.setAdapter(adapter); datePickerButton = (Button) findViewById(R.id.button_datepicker); datePickerButton.setText(modifiedDate); datePickerButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub FragmentManager dialogManager = getFragmentManager(); CalendarDialogFragment calendarDialogFragment = new CalendarDialogFragment(); calendarDialogFragment.setParentCaller(CalendarDialogFragment.PARENT_IS_ACTIVITY); calendarDialogFragment.show(dialogManager, "calendar_dialog_popped"); } }); // Activity emailAddress(SESSION_ID) MyPageFragment // . // searchButton = (ImageButton) findViewById(R.id.imageButton_search); searchButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub try { String region = locationSelectSpinner.getSelectedItem().toString(); if (region.equals("")) { region = "1"; } else if (region.equals("")) { region = "2"; } else { region = "3"; } String people = ((EditText) findViewById(R.id.editText_numberPeople)).getText().toString(); String[] tmp = (datePickerButton.getText().toString()).split(" "); String date = tmp[0].substring(0, 4) + "-" + tmp[1].split("")[0] + "-" + tmp[2].split("")[0]; String query = "?region=" + region + "&people=" + people + "&date=" + date + "&flag=1"; sendInfoToFragment(people, 2); sendInfoToFragment(query, 0); getSlidingMenu().showContent(); } catch (Exception e) { // TODO Auto-generated catch block Toast.makeText(getApplicationContext(), " ", Toast.LENGTH_SHORT); e.printStackTrace(); } } }); }
From source file:com.androzic.waypoint.WaypointProperties.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Androzic application = Androzic.getApplication(); View rootView = inflater.inflate(R.layout.act_waypoint_properties, container, false); tabHost = (TabHost) rootView.findViewById(R.id.tabhost); tabHost.setup();//ww w.ja v a 2 s .c o m tabHost.addTab( tabHost.newTabSpec("main").setIndicator(getString(R.string.primary)).setContent(R.id.properties)); tabHost.addTab(tabHost.newTabSpec("advanced").setIndicator(getString(R.string.advanced)) .setContent(R.id.advanced)); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { tabHost.getTabWidget().getChildAt(0).getLayoutParams().height = 50; tabHost.getTabWidget().getChildAt(1).getLayoutParams().height = 50; } name = (TextView) rootView.findViewById(R.id.name_text); description = (TextView) rootView.findViewById(R.id.description_text); altitude = (TextView) rootView.findViewById(R.id.altitude_text); proximity = (TextView) rootView.findViewById(R.id.proximity_text); iconValue = null; ImageButton icon = (ImageButton) rootView.findViewById(R.id.icon_button); icon.setImageDrawable(getResources().getDrawable(R.drawable.ic_highlight_remove_white_24dp)); if (waypoint.drawImage) { Bitmap b = BitmapFactory.decodeFile(application.markerPath + File.separator + waypoint.marker); if (b != null) { icon.setImageBitmap(b); iconValue = waypoint.marker; } } icon.setOnClickListener(iconOnClickListener); ArrayList<String> items = new ArrayList<String>(); for (WaypointSet wptset : application.getWaypointSets()) { items.add(wptset.name); } waypointSet = (Spinner) rootView.findViewById(R.id.set_spinner); ArrayAdapter<String> adapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_spinner_item, items); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); waypointSet.setAdapter(adapter); markercolor = (ColorButton) rootView.findViewById(R.id.markercolor_button); textcolor = (ColorButton) rootView.findViewById(R.id.textcolor_button); coordDeg = (ViewGroup) rootView.findViewById(R.id.coord_deg); coordUtm = (ViewGroup) rootView.findViewById(R.id.coord_utm); coordMgrs = (ViewGroup) rootView.findViewById(R.id.coord_mgrs); coordLatDeg = (ViewGroup) rootView.findViewById(R.id.coord_lat_deg); coordLatMin = (ViewGroup) rootView.findViewById(R.id.coord_lat_min); coordLatSec = (ViewGroup) rootView.findViewById(R.id.coord_lat_sec); coordLonDeg = (ViewGroup) rootView.findViewById(R.id.coord_lon_deg); coordLonMin = (ViewGroup) rootView.findViewById(R.id.coord_lon_min); coordLonSec = (ViewGroup) rootView.findViewById(R.id.coord_lon_sec); Spinner coordformat = (Spinner) rootView.findViewById(R.id.coordformat_spinner); coordformat.setOnItemSelectedListener(this); coordformat.setSelection(StringFormatter.coordinateFormat); return rootView; }
From source file:de.uni_koblenz_landau.apow.LoginActivity.java
@Override public void onLocationsFetched(List<ListViewItem> result) { mLocationWebTask = null;// w ww. j a v a 2 s .c o m showProgress(false); if (result != null) { mLocations = result; ArrayAdapter<ListViewItem> adapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, result); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mSetupLocationView.setAdapter(adapter); } else { // show error Toast.makeText(this, R.string.error_connection, Toast.LENGTH_SHORT).show(); } }
From source file:com.todoroo.astrid.repeats.RepeatControlSet.java
@Nullable @Override//from w w w . j a v a2s . c o m public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = super.onCreateView(inflater, container, savedInstanceState); if (savedInstanceState != null) { recurrence = savedInstanceState.getString(EXTRA_RECURRENCE); repeatUntilValue = savedInstanceState.getLong(EXTRA_REPEAT_UNTIL); repeatAfterCompletion = savedInstanceState.getBoolean(EXTRA_REPEAT_AFTER_COMPLETION); } dialogView = inflater.inflate(R.layout.control_set_repeat, null); value = (Button) dialogView.findViewById(R.id.repeatValue); Spinner interval = (Spinner) dialogView.findViewById(R.id.repeatInterval); ArrayAdapter<String> intervalAdapter = new ArrayAdapter<>(context, android.R.layout.simple_spinner_item, getResources().getStringArray(R.array.repeat_interval)); intervalAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); interval.setAdapter(intervalAdapter); Spinner type = (Spinner) dialogView.findViewById(R.id.repeatType); ArrayAdapter<String> typeAdapter = new ArrayAdapter<>(context, android.R.layout.simple_spinner_item, getResources().getStringArray(R.array.repeat_type)); typeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); type.setAdapter(typeAdapter); type.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { repeatAfterCompletion = position == TYPE_COMPLETION_DATE; } @Override public void onNothingSelected(AdapterView<?> parent) { } }); daysOfWeekContainer = (LinearLayout) dialogView.findViewById(R.id.repeatDayOfWeekContainer); repeatUntil = (Spinner) dialogView.findViewById(R.id.repeat_until); repeatUntilAdapter = new ArrayAdapter<>(context, android.R.layout.simple_spinner_item, repeatUntilOptions); repeatUntilAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); repeatUntil.setAdapter(repeatUntilAdapter); // set up days of week DateFormatSymbols dfs = new DateFormatSymbols(); Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.DAY_OF_WEEK, calendar.getFirstDayOfWeek()); CompoundButton[] daysOfWeek = new CompoundButton[7]; for (int i = 0; i < 7; i++) { final int index = i; CheckBox checkBox = (CheckBox) daysOfWeekContainer.getChildAt(i); checkBox.setOnCheckedChangeListener( (buttonView, isChecked1) -> RepeatControlSet.this.isChecked[index] = isChecked1); int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK); checkBox.setText(dfs.getShortWeekdays()[dayOfWeek].substring(0, 1)); daysOfWeek[i] = checkBox; weekdays[i] = Weekday.values()[dayOfWeek - 1]; calendar.add(Calendar.DATE, 1); } // set up listeners value.setOnClickListener(v -> repeatValueClick()); setRepeatValue(1); interval.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parentView, View view, int position, long id) { daysOfWeekContainer.setVisibility(position == INTERVAL_WEEKS ? View.VISIBLE : View.GONE); intervalValue = position; } @Override public void onNothingSelected(AdapterView<?> arg0) { // } }); setRepeatUntilValue(repeatUntilValue); repeatUntil.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { if (repeatUntilOptions.size() == 2) { if (i == 0) { setRepeatUntilValue(0); } else { repeatUntilClick(); } } else { if (i == 1) { setRepeatUntilValue(0); } else if (i == 2) { repeatUntilClick(); } } } @Override public void onNothingSelected(AdapterView<?> adapterView) { // } }); daysOfWeekContainer.setVisibility(View.GONE); type.setSelection(repeatAfterCompletion ? TYPE_COMPLETION_DATE : TYPE_DUE_DATE); doRepeat = !Strings.isNullOrEmpty(recurrence); if (doRepeat) { // read recurrence rule try { RRule rrule = new RRule(recurrence); setRepeatValue(rrule.getInterval()); for (WeekdayNum day : rrule.getByDay()) { for (int i = 0; i < 7; i++) { if (weekdays[i].equals(day.wday)) { daysOfWeek[i].setChecked(true); } } } switch (rrule.getFreq()) { case DAILY: intervalValue = INTERVAL_DAYS; break; case WEEKLY: intervalValue = INTERVAL_WEEKS; break; case MONTHLY: intervalValue = INTERVAL_MONTHS; break; case HOURLY: intervalValue = INTERVAL_HOURS; break; case MINUTELY: intervalValue = INTERVAL_MINUTES; break; case YEARLY: intervalValue = INTERVAL_YEARS; break; default: Timber.e(new Exception("Unhandled rrule frequency: " + recurrence), "repeat-unhandled-rule"); } interval.setSelection(intervalValue); } catch (Exception e) { // invalid RRULE recurrence = ""; //$NON-NLS-1$ Timber.e(e, e.getMessage()); } } refreshDisplayView(); return view; }
From source file:edu.usf.cutr.opentripplanner.android.fragments.DirectionListFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); ImageButton btnDisplayMap = (ImageButton) header.findViewById(R.id.btnDisplayMap); ImageButton btnShareDirections = (ImageButton) header.findViewById(R.id.btnShareDirections); ImageButton btnAlarmDirections = (ImageButton) header.findViewById(R.id.btnAlarmDirections); final OtpFragment ofl = this.getFragmentListener(); final DirectionListFragment dlf = this; OnClickListener oclDisplayDirection = new OnClickListener() { @Override/* w ww .ja va 2 s . co m*/ public void onClick(View arg0) { ofl.onSwitchedToMainFragment(dlf); } }; btnDisplayMap.setOnClickListener(oclDisplayDirection); btnShareDirections.setOnClickListener(new OnClickListener() { public void onClick(View v) { // create popup menu View menuItemView = getView().findViewById(R.id.btnShareDirections); PopupMenu popup = new PopupMenu(getActivity(), menuItemView); popup.getMenuInflater().inflate(R.menu.share_menu, popup.getMenu()); menuItemView.setOnTouchListener(PopupMenuCompat.getDragToOpenListener(popup)); //registering popup with OnMenuItemClickListener popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { Intent itn = new Intent(); itn.setAction(Intent.ACTION_SEND); itn.setType("text/plain"); // fill intend content based on chosen menu item switch (item.getItemId()) { case R.id.btnShareDirectionsShort: itn.putExtra(Intent.EXTRA_TEXT, getDepartureArrivalHeaders(false)); break; case R.id.btnShareDirectionsDetailed: itn.putExtra(Intent.EXTRA_TEXT, getDepartureArrivalHeaders(true)); break; default: break; } startActivity(Intent.createChooser(itn, "Share via")); return true; } }); popup.show(); } }); btnAlarmDirections.setOnClickListener(new OnClickListener() { public void onClick(View v) { // create popup menu View menuItemView = getView().findViewById(R.id.btnAlarmDirections); PopupMenu popup = new PopupMenu(getActivity(), menuItemView); popup.getMenuInflater().inflate(R.menu.alarm_menu, popup.getMenu()); menuItemView.setOnTouchListener(PopupMenuCompat.getDragToOpenListener(popup)); //registering popup with OnMenuItemClickListener popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { switch (item.getItemId()) { case R.id.btnAlarmDirectionsAlarm: setAlarmItinerary(); break; case R.id.btnAlarmDirectionsNotifications: setNotificationsItinerary(); break; case R.id.btnAlarmDirectionsCalendar: setCalendarItinerary(); break; default: break; } return true; } }); popup.show(); } }); fromHeader = (TextView) header.findViewById(R.id.fromHeader); toHeader = (TextView) header.findViewById(R.id.toHeader); departureTimeHeader = (TextView) header.findViewById(R.id.departureTimeHeader); arrivalTimeHeader = (TextView) header.findViewById(R.id.arrivalTimeHeader); tripList = (Spinner) header.findViewById(R.id.itinerarySelection); if (savedInstanceState != null) { otpBundle = (OTPBundle) savedInstanceState.getSerializable(OTPApp.BUNDLE_KEY_OTP_BUNDLE); fragmentListener.setOTPBundle(otpBundle); } else { otpBundle = fragmentListener.getOTPBundle(); } fromHeader.setText(otpBundle.getFromText()); toHeader.setText(otpBundle.getToText()); setDepartureArrivalHeaders(); ArrayList<Leg> currentItinerary = new ArrayList<Leg>(); currentItinerary.addAll(fragmentListener.getCurrentItinerary()); ArrayList<Itinerary> itineraryList = new ArrayList<Itinerary>(); itineraryList.addAll(fragmentListener.getCurrentItineraryList()); int currentItineraryIndex = fragmentListener.getCurrentItineraryIndex(); ArrayList<Direction> directions = new ArrayList<Direction>(); DirectionsGenerator dirGen = new DirectionsGenerator(currentItinerary, getActivity().getApplicationContext()); ArrayList<Direction> tempDirections = dirGen.getDirections(); if (tempDirections != null && !tempDirections.isEmpty()) { directions.addAll(tempDirections); } final Activity activity = this.getActivity(); String[] itinerarySummaryList = new String[itineraryList.size()]; boolean isTransitIsTagSet = false; for (int i = 0; i < itinerarySummaryList.length; i++) { isTransitIsTagSet = false; Itinerary it = itineraryList.get(i); for (Leg leg : it.legs) { TraverseMode traverseMode = TraverseMode.valueOf(leg.mode); if (traverseMode.isTransit()) { itinerarySummaryList[i] = ConversionUtils.getRouteShortNameSafe(leg.routeShortName, leg.routeLongName, getActivity().getApplicationContext()) + ". "; isTransitIsTagSet = true; break; } } if (!isTransitIsTagSet) { itinerarySummaryList[i] = Integer.toString(i + 1) + ". ";//Shown index is i + 1, to use 1-based indexes for the UI instead of 0-based } } for (int i = 0; i < itinerarySummaryList.length; i++) { Itinerary it = itineraryList.get(i); long tripDuration; if (PreferenceManager.getDefaultSharedPreferences(getActivity().getApplicationContext()) .getInt(OTPApp.PREFERENCE_KEY_API_VERSION, OTPApp.API_VERSION_V1) == OTPApp.API_VERSION_V1) { tripDuration = it.duration; } else { tripDuration = it.duration / 1000; } itinerarySummaryList[i] += getString(R.string.step_by_step_total_duration) + " " + ConversionUtils .getFormattedDurationTextNoSeconds(tripDuration, false, getActivity().getApplicationContext()); if (isTransitIsTagSet) { itinerarySummaryList[i] += " " + getString(R.string.step_by_step_walking_duration) + " " + ConversionUtils.getFormattedDurationTextNoSeconds(it.walkTime, false, getActivity().getApplicationContext()); } } ArrayAdapter<String> itineraryAdapter = new ArrayAdapter<String>(activity, android.R.layout.simple_spinner_item, itinerarySummaryList); itineraryAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); tripList.setAdapter(itineraryAdapter); AdapterView.OnItemSelectedListener itinerarySpinnerListener = new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { if (fragmentListener.getCurrentItineraryIndex() != position) { fragmentListener.onItinerarySelected(position, 3); } setDepartureArrivalHeaders(); if (!isFragmentFirstLoad) { ArrayList<Direction> directions = new ArrayList<Direction>(); DirectionsGenerator dirGen = new DirectionsGenerator(fragmentListener.getCurrentItinerary(), getActivity().getApplicationContext()); ArrayList<Direction> tempDirections = dirGen.getDirections(); if (tempDirections != null && !tempDirections.isEmpty()) { directions.addAll(tempDirections); } Direction direction_data[] = directions.toArray(new Direction[directions.size()]); DirectionExpandableListAdapter adapter = new DirectionExpandableListAdapter( DirectionListFragment.this.getActivity(), R.layout.list_direction_item, R.layout.list_subdirection_item, direction_data); elv.setAdapter(adapter); } openIfNonTransit(); isFragmentFirstLoad = false; } @Override public void onNothingSelected(AdapterView<?> parent) { } }; tripList.setSelection(currentItineraryIndex); tripList.setOnItemSelectedListener(itinerarySpinnerListener); // Populate list with our static array of titles. elv = getExpandableListView(); Direction direction_data[] = directions.toArray(new Direction[directions.size()]); DirectionExpandableListAdapter adapter = new DirectionExpandableListAdapter(this.getActivity(), R.layout.list_direction_item, R.layout.list_subdirection_item, direction_data); elv.addHeaderView(header); elv.setAdapter(adapter); elv.setGroupIndicator(null); // Get rid of the down arrow openIfNonTransit(); if (savedInstanceState == null) { if (otpBundle.isFromInfoWindow()) { elv.expandGroup(otpBundle.getCurrentStepIndex()); elv.setSelectedGroup(otpBundle.getCurrentStepIndex()); otpBundle.setFromInfoWindow(false); } } }
From source file:com.zira.registration.BackgroundCheckActivity.java
private void setApapterForCity() { ArrayAdapter<City> dataAdapter = new ArrayAdapter<City>(this, R.layout.spinner_list, arraylist_city); dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); citySpinner.setAdapter(dataAdapter); citySpinner.setSelection(gettingCityPosition); }
From source file:com.zira.registration.VehicleInformationActivity.java
protected void setApapterForCountry() { ArrayAdapter<Country> dataAdapter = new ArrayAdapter<Country>(this, R.layout.spinner_list, countryList); dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); countryNameSpinner.setAdapter(dataAdapter); if (SingleTon.getInstance().isEdited()) { countryNameSpinner.setSelection(gettingCountryPosition); }/*from w w w . j av a2s. co m*/ }
From source file:course1778.mobileapp.safeMedicare.Main.FamMemFrag.java
private void add() { LayoutInflater inflater = getActivity().getLayoutInflater(); View addView = inflater.inflate(R.layout.add_edit, null); //AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); AlertDialog.Builder builder = new AlertDialog.Builder( new ContextThemeWrapper(getContext(), R.style.AlertDialogCustom)); builder.setTitle(R.string.add_title).setView(addView).setPositiveButton(R.string.ok, this) .setNegativeButton(R.string.cancel, null).show(); Spinner spin = (Spinner) addView.findViewById(R.id.spinner); //spin.setOnItemSelectedListener(FamMemActivity.getContext()); ArrayAdapter<String> aa = new ArrayAdapter<String>(FamMemActivity.getContext(), R.layout.spinner_item_text, items);/*from w ww. j av a 2 s . co m*/ aa.setDropDownViewResource(R.layout.spinner_dropdown_item); spin.setAdapter(aa); // field for user adding medication name textView = (AutoCompleteTextView) addView.findViewById(R.id.title); /** sheet 1 displays all the drug interactions; * sheet 2 displays the list of all drugs */ crsList = med_list.rawQuery("SELECT * FROM Sheet1", null); crsInteractions = med_interaction.rawQuery("SELECT * FROM DrugDrug", null); String[] array = new String[crsList.getCount()]; int i = 0; while (crsList.moveToNext()) { String uname = crsList.getString(crsList.getColumnIndex("Name")); array[i] = uname; i++; } // Create the adapter and set it to the AutoCompleteTextView ArrayAdapter<String> adapter = new ArrayAdapter<String>(FamMemActivity.getContext(), R.layout.listlayout, R.id.listTextView, array); textView.setAdapter(adapter); }