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.chaitu.lmscalendar.ui.UrlDialog.java
@Override @NonNull/*from www . ja v a 2s . c o m*/ public Dialog onCreateDialog(Bundle savedInstanceState) { mActivity = (MainActivity) getActivity(); ViewGroup nullViewGroup = null; // Avoid bad lint warning in inflate() View view = mActivity.getLayoutInflater().inflate(R.layout.urldialog, nullViewGroup); mTextCalendarUrl = (EditText) view.findViewById(R.id.TextCalendarUrl); mTextUsername = (EditText) view.findViewById(R.id.TextUsername); mTextPassword = (EditText) view.findViewById(R.id.TextPassword); Settings settings = mActivity.getSettings(); mTextCalendarUrl.setText(settings.getString(Settings.PREF_LASTURL)); mTextUsername.setText(settings.getString(Settings.PREF_LASTURLUSERNAME)); mTextPassword.setText(settings.getString(Settings.PREF_LASTURLPASSWORD)); mTextCalendarUrl.selectAll(); //sync intervals mSpinnerSyncInterval = (Spinner) view.findViewById(R.id.sync_interval); // Create an ArrayAdapter using the string array and a default spinner layout ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(mActivity.getApplicationContext(), R.array.sync_intervals, 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 mSpinnerSyncInterval.setAdapter(adapter); mSpinnerCalendar = (Spinner) view.findViewById(R.id.calendar); //calendar List<CalendarModel> calendars = EventUtil.readCalendars(mActivity.getApplicationContext(), mActivity.getApplicationContext().getContentResolver()); ArrayAdapter<CalendarModel> adapter1 = new ArrayAdapter<CalendarModel>(mActivity.getApplicationContext(), android.R.layout.simple_spinner_dropdown_item, calendars); mSpinnerCalendar.setAdapter(adapter1); String name = settings.getString(Settings.PREF_LASTCALENDARNAME); int id = settings.getInt(Settings.PREF_LASTCALENDARID); if (id > 0 && name != null && !name.isEmpty()) { CalendarModel cal = new CalendarModel(id, name); mSpinnerCalendar.setSelection(adapter1.getPosition(cal)); } DialogInterface.OnClickListener okTask; okTask = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface iface, int id) { // We override this in onStart() } }; DialogInterface.OnClickListener cancelTask; cancelTask = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface iface, int id) { iface.cancel(); } }; AlertDialog.Builder builder = new AlertDialog.Builder(mActivity); AlertDialog dlg = builder.setIcon(R.mipmap.ic_launcher).setTitle(R.string.enter_source_url).setView(view) .setPositiveButton(android.R.string.ok, okTask) .setNegativeButton(android.R.string.cancel, cancelTask).create(); dlg.getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); return dlg; }
From source file:com.mifos.mifosxdroid.online.savingaccounttransaction.SavingsAccountTransactionFragment.java
@Override public void showSavingAccountTemplate( final SavingsAccountTransactionTemplate savingsAccountTransactionTemplate) { if (savingsAccountTransactionTemplate != null) { List<String> listOfPaymentTypes = Utils .getPaymentTypeOptions(savingsAccountTransactionTemplate.getPaymentTypeOptions()); ArrayAdapter<String> paymentTypeAdapter = new ArrayAdapter<>(getActivity(), layout.simple_spinner_item, listOfPaymentTypes);/* ww w .j a va 2s.c om*/ paymentTypeAdapter.setDropDownViewResource(layout.simple_spinner_dropdown_item); sp_paymentType.setAdapter(paymentTypeAdapter); sp_paymentType.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { paymentTypeOptionId = savingsAccountTransactionTemplate.getPaymentTypeOptions().get(position) .getId(); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); } }
From source file:com.mifos.mifosxdroid.dialogfragments.LoanChargeDialogFragment.java
private void inflateChargesSpinner() { showProgress(true);//from ww w. j a v a 2s .co m App.apiManager.getAllChargesV3(loanAccountNumber, new Callback<Response>() { @Override public void success(final Response result, Response response) { /* Activity is null - Fragment has been detached; no need to do anything. */ if (getActivity() == null) return; Log.d(LOG_TAG, ""); final List<Charges> charges = new ArrayList<>(); // you can use this array to populate your spinner final ArrayList<String> chargesNames = new ArrayList<String>(); //Try to get response body BufferedReader reader = null; StringBuilder sb = new StringBuilder(); try { reader = new BufferedReader(new InputStreamReader(result.getBody().in())); String line; while ((line = reader.readLine()) != null) { sb.append(line); } JSONObject obj = new JSONObject(sb.toString()); if (obj.has("chargeOptions")) { JSONArray chargesTypes = obj.getJSONArray("chargeOptions"); for (int i = 0; i < chargesTypes.length(); i++) { JSONObject chargesObject = chargesTypes.getJSONObject(i); Charges charge = new Charges(); charge.setId(chargesObject.optInt("id")); charge.setName(chargesObject.optString("name")); charges.add(charge); chargesNames.add(chargesObject.optString("name")); chargeNameIdHashMap.put(charge.getName(), charge.getId()); } } String stringResult = sb.toString(); } catch (Exception e) { Log.e(LOG_TAG, "", e); } final ArrayAdapter<String> chargesAdapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_spinner_item, chargesNames); chargesAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); sp_charge_name.setAdapter(chargesAdapter); sp_charge_name.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { Id = chargeNameIdHashMap.get(chargesNames.get(i)); Log.d("chargesoptionss" + chargesNames.get(i), String.valueOf(Id)); if (Id != -1) { } else { Toast.makeText(getActivity(), getString(R.string.error_select_charge), Toast.LENGTH_SHORT).show(); } } @Override public void onNothingSelected(AdapterView<?> parent) { } }); showProgress(false); } @Override public void failure(RetrofitError retrofitError) { Log.d(LOG_TAG, retrofitError.getLocalizedMessage()); showProgress(false); } }); }
From source file:com.nkana.app.fragment.QuestionerFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // TODO Auto-generated method stub View rootView = inflater.inflate(R.layout.mentor_tracking_details, container, false); rootView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); preferences = getActivity().getSharedPreferences(IConstants.AUTH_TOKEN, getActivity().MODE_PRIVATE); authKey = preferences.getString(IConstants.AUTHORIZATION, null); spinner0 = (Spinner) rootView.findViewById(R.id.spinner0); ArrayAdapter<String> adapter0 = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_spinner_item, text0); adapter0.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner0.setAdapter(adapter0);/*from ww w . j a va 2 s .c o m*/ spinner0.setOnItemSelectedListener(onItemSelectedListener0); spinner1 = (Spinner) rootView.findViewById(R.id.spinner1); ArrayAdapter<String> adapter1 = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_spinner_item, text1); adapter1.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner1.setAdapter(adapter1); spinner1.setOnItemSelectedListener(onItemSelectedListener0); spinner2 = (Spinner) rootView.findViewById(R.id.spinner2); ArrayAdapter<String> adapter2 = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_spinner_item, text1); //adapter2.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner2.setAdapter(adapter2); spinner2.setOnItemSelectedListener(onItemSelectedListener0); spinner3 = (Spinner) rootView.findViewById(R.id.spinner3); ArrayAdapter<String> adapter3 = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_spinner_item, text1); //adapter2.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner3.setAdapter(adapter3); spinner3.setOnItemSelectedListener(onItemSelectedListener0); spinner4 = (Spinner) rootView.findViewById(R.id.spinner4); ArrayAdapter<String> adapter4 = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_spinner_item, text1); //adapter2.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner4.setAdapter(adapter4); spinner4.setOnItemSelectedListener(onItemSelectedListener0); spinner5 = (Spinner) rootView.findViewById(R.id.spinner5); ArrayAdapter<String> adapter5 = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_spinner_item, text1); //adapter2.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner5.setAdapter(adapter5); spinner5.setOnItemSelectedListener(onItemSelectedListener0); spinner6 = (Spinner) rootView.findViewById(R.id.spinner6); ArrayAdapter<String> adapter6 = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_spinner_item, text1); //adapter2.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner6.setAdapter(adapter6); spinner6.setOnItemSelectedListener(onItemSelectedListener0); spinner7 = (Spinner) rootView.findViewById(R.id.spinner7); ArrayAdapter<String> adapter7 = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_spinner_item, text1); //adapter2.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner7.setAdapter(adapter7); spinner7.setOnItemSelectedListener(onItemSelectedListener0); spinner8 = (Spinner) rootView.findViewById(R.id.spinner8); ArrayAdapter<String> adapter8 = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_spinner_item, text1); //adapter2.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner8.setAdapter(adapter8); spinner8.setOnItemSelectedListener(onItemSelectedListener0); spinner9 = (Spinner) rootView.findViewById(R.id.spinner9); ArrayAdapter<String> adapter9 = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_spinner_item, text1); //adapter2.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner9.setAdapter(adapter9); spinner9.setOnItemSelectedListener(onItemSelectedListener0); // getGroupsList(); return rootView; }
From source file:com.creationgroundmedia.taskmaster.TaskDetailFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mView = inflater.inflate(R.layout.task_detail, container, false); mNameView = (EditText) mView.findViewById(R.id.task_detail_name); mDescriptionView = (EditText) mView.findViewById(R.id.task_detail_description); mDateView = (DatePicker) mView.findViewById(R.id.task_detail_due_date); mCompletedView = (CheckBox) mView.findViewById(R.id.task_detail_status); ArrayAdapter<CharSequence> spinnerAdapter = ArrayAdapter.createFromResource(mContext, R.array.priority, android.R.layout.simple_spinner_item); spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mPriorityView = (Spinner) mView.findViewById(R.id.task_detail_priority); mPriorityView.setAdapter(spinnerAdapter); mPriorityView.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override/*ww w . ja v a2s . com*/ public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { mPriority = (String) parent.getItemAtPosition(position); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); if (mNewTask) { // Make "normal" the default priority. // the position for "normal" should be 1 mPriorityView.setSelection(1); mPriority = mPriorityView.getSelectedItem().toString(); } Button saveView = (Button) mView.findViewById(R.id.save); saveView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { saveData(); if (mNewTask) { dismiss(); } } }); if (!mBackFromRotation && !mNewTask) { mCursorLoader = getActivity().getSupportLoaderManager().initLoader(URL_LOADER, null, this); } return mView; }
From source file:com.example.android.lnotifications.OtherMetadataFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); mShowNotificationButton = (Button) view.findViewById(R.id.show_notification_button); mShowNotificationButton.setOnClickListener(new View.OnClickListener() { @Override/*from w w w. ja va2 s . com*/ public void onClick(View view) { Priority selectedPriority = (Priority) mPrioritySpinner.getSelectedItem(); Category selectedCategory = (Category) mCategorySpinner.getSelectedItem(); showNotificationClicked(selectedPriority, selectedCategory, mContactUri); } }); mCategorySpinner = (Spinner) view.findViewById(R.id.category_spinner); ArrayAdapter<Category> categoryArrayAdapter = new ArrayAdapter<Category>(getActivity(), android.R.layout.simple_spinner_item, Category.values()); categoryArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mCategorySpinner.setAdapter(categoryArrayAdapter); mPrioritySpinner = (Spinner) view.findViewById(R.id.priority_spinner); ArrayAdapter<Priority> priorityArrayAdapter = new ArrayAdapter<Priority>(getActivity(), android.R.layout.simple_spinner_item, Priority.values()); priorityArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mPrioritySpinner.setAdapter(priorityArrayAdapter); view.findViewById(R.id.attach_person).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { findContact(); } }); view.findViewById(R.id.contact_entry).setVisibility(View.GONE); }
From source file:com.gmail.taneza.ronald.carbs.myfoods.MyFoodDetailsActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_my_food_details); getSupportActionBar().setDisplayHomeAsUpEnabled(true); mFoodDbAdapter = ((CarbsApp) getApplication()).getFoodDbAdapter(); // Get the message from the intent Intent intent = getIntent();/*from w w w. ja v a 2 s .com*/ mFoodItem = intent.getParcelableExtra(MY_FOOD_ITEM_MESSAGE); FoodItemInfo foodItemInfo; Mode mode = Mode.values()[intent.getIntExtra(MY_FOOD_ACTIVITY_MODE_MESSAGE, Mode.NewFood.ordinal())]; mMode = mode; if (mode == Mode.NewFood) { foodItemInfo = new FoodItemInfo(mFoodItem, NEW_FOOD_DEFAULT_NAME, NEW_FOOD_DEFAULT_QUANTITY_PER_UNIT, NEW_FOOD_DEFAULT_CARBS, NEW_FOOD_DEFAULT_UNIT_TEXT); } else { foodItemInfo = mFoodDbAdapter.getFoodItemInfo(mFoodItem); setTitle(R.string.title_activity_my_food_edit); Button okButton = (Button) findViewById(R.id.my_food_ok_button); okButton.setText(R.string.save_food_details); } mFoodNameTextView = (TextView) findViewById(R.id.my_food_name); mFoodNameTextView.setText(foodItemInfo.getName()); // Request focus and show soft keyboard automatically mFoodNameTextView.requestFocus(); getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_VISIBLE); mQuantityEditText = (EditText) findViewById(R.id.my_food_quantity_edit); mQuantityEditText.setText(Integer.toString(foodItemInfo.getQuantityPerUnit())); mQuantityUnitTextSpinner = (Spinner) findViewById(R.id.my_food_quantity_unit_spinner); // Create an ArrayAdapter using the string array and a default spinner layout ArrayAdapter<CharSequence> arrayAdapter = ArrayAdapter.createFromResource(this, R.array.quantity_unit_text_array, android.R.layout.simple_spinner_item); // Specify the layout to use when the list of choices appears arrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); // Apply the adapter to the spinner mQuantityUnitTextSpinner.setAdapter(arrayAdapter); mQuantityUnitTextSpinner.setSelection(arrayAdapter.getPosition(foodItemInfo.getUnitText())); mNumCarbsTextView = (TextView) findViewById(R.id.my_food_carbs); // Display decimal place only when non-zero, so it's easier to edit String numCarbsString; float numCarbs = foodItemInfo.getNumCarbsInGrams(); if (numCarbs == (int) numCarbs) { numCarbsString = String.format(Locale.getDefault(), "%.0f", numCarbs); } else { numCarbsString = String.format(Locale.getDefault(), "%.1f", numCarbs); } mNumCarbsTextView.setText(numCarbsString); }
From source file:com.dawkinstan.simplebalance.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); this.actionbar = getSupportActionBar(); this.actionbar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); this.actionbar.addTab(this.actionbar.newTab().setText("Balance").setTabListener(this)); this.actionbar.addTab(this.actionbar.newTab().setText("Transactions").setTabListener(this)); this.type = -1; // Setting display where money is shown as unclickable EditText cmDisplay;//from w w w . j a v a2 s. c om cmDisplay = (EditText) findViewById(R.id.currentAmount); cmDisplay.setClickable(false); cmDisplay.setFocusable(false); Spinner spinner = (Spinner) findViewById(R.id.type_spinner); ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.type_array, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter); new Spr(); // Getting preferences SharedPreferences settings = getSharedPreferences(PREFS_NAME, MODE_PRIVATE); boolean firstLoad = settings.getBoolean("firstLoad", true); ds = new DataSource(this); if (firstLoad) { // First load intent Intent intent = new Intent(this, MTSettings.class); try { startActivityForResult(intent, 1); SharedPreferences.Editor edit = settings.edit(); edit.putBoolean("firstLoad", false); edit.commit(); } // Catches exception of the activity not existing catch (Exception e) { } } else { // Formats string to have money symbol in front. double currentMoney; try { currentMoney = Double.parseDouble(settings.getString("ammount", "0.00").replace("$|,", "")); } catch (Exception e) { currentMoney = 0; } this.setNewAmountInView(currentMoney); this.beforePurchase = currentMoney; } // Sets button as unclickable Button updateButton = (Button) findViewById(R.id.button_update); updateButton.setEnabled(false); // Listener to update the view of the ammount of money changed updateButton.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { onUpdate(view); } }); }
From source file:com.mifos.mifosxdroid.online.CreateNewGroupFragment.java
private void inflateOfficeSpinner() { showProgress(true);//from ww w . j ava 2s .c o m App.apiManager.getOffices(new Callback<List<Office>>() { @Override public void success(List<Office> offices, Response response) { /* Activity is null - Fragment has been detached; no need to do anything. */ if (getActivity() == null) return; final ArrayList<String> officeList = new ArrayList<String>(); for (Office office : offices) { officeList.add(office.getName()); officeNameIdHashMap.put(office.getName(), office.getId()); } ArrayAdapter<String> officeAdapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_spinner_item, officeList); officeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); sp_offices.setAdapter(officeAdapter); sp_offices.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { officeId = officeNameIdHashMap.get(officeList.get(i)); Log.d("officeId " + officeList.get(i), String.valueOf(officeId)); if (officeId != -1) { } else { Toast.makeText(getActivity(), getString(R.string.error_select_office), Toast.LENGTH_SHORT).show(); } } @Override public void onNothingSelected(AdapterView<?> parent) { } }); showProgress(false); } @Override public void failure(RetrofitError retrofitError) { Log.d(LOG_TAG, retrofitError.getLocalizedMessage()); } }); }
From source file:de.eidottermihi.rpicheck.activity.NewRaspiAuthActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_raspi_new_auth); // Show the Up button in the action bar. getSupportActionBar().setDisplayHomeAsUpEnabled(true); // show default option for auth method = ssh password this.switchAuthMethodsInView(SPINNER_AUTH_METHODS[0]); // init auth spinner final ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.auth_methods, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); // Apply the adapter to the spinner spinnerAuth.setAdapter(adapter);/*from ww w .j a v a 2s .c o m*/ spinnerAuth.setOnItemSelectedListener(this); // init sql db deviceDb = new DeviceDbHelper(this); // get data from previous screen (name/host/user...), already validated final Bundle piData = this.getIntent().getExtras().getBundle(NewRaspiActivity.PI_BUNDLE); host = piData.getString(NewRaspiActivity.PI_HOST); name = piData.getString(NewRaspiActivity.PI_NAME); user = piData.getString(NewRaspiActivity.PI_USER); desc = piData.getString(NewRaspiActivity.PI_DESC); }