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.mifos.mifosxdroid.online.SavingsAccountFragment.java
private void inflateSavingsSpinner() { showProgress(true);/*from ww w .j ava 2 s .co m*/ App.apiManager.getSavingsAccounts(new Callback<List<ProductSavings>>() { @Override public void success(List<ProductSavings> savings, Response response) { /* Activity is null - Fragment has been detached; no need to do anything. */ if (getActivity() == null) return; final List<String> savingsList = new ArrayList<String>(); for (ProductSavings savingsname : savings) { savingsList.add(savingsname.getName()); savingsNameIdHashMap.put(savingsname.getName(), savingsname.getId()); } ArrayAdapter<String> savingsAdapter = new ArrayAdapter<>(getActivity(), layout.simple_spinner_item, savingsList); savingsAdapter.setDropDownViewResource(layout.simple_spinner_dropdown_item); sp_product.setAdapter(savingsAdapter); sp_product.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { productId = savingsNameIdHashMap.get(savingsList.get(i)); Log.d("productId " + savingsList.get(i), String.valueOf(productId)); if (productId != -1) { } else { Toast.makeText(getActivity(), getString(R.string.error_select_product), Toast.LENGTH_SHORT).show(); } } @Override public void onNothingSelected(AdapterView<?> parent) { } }); showProgress(false); } @Override public void failure(RetrofitError retrofitError) { showProgress(false); } }); }
From source file:com.mifos.mifosxdroid.online.LoanRepaymentFragment.java
public void inflatePaymentOptions() { App.apiManager.getLoanRepayTemplate(Integer.parseInt(loanAccountNumber), new Callback<LoanRepaymentTemplate>() { @Override//from ww w . java 2s . com public void success(LoanRepaymentTemplate loanRepaymentTemplate, Response response) { /* Activity is null - Fragment has been detached; no need to do anything. */ if (getActivity() == null) return; if (loanRepaymentTemplate != null) { tv_amountDue.setText(String.valueOf(loanRepaymentTemplate.getAmount())); inflateRepaymentDate(); List<String> listOfPaymentTypes = new ArrayList<String>(); paymentTypeOptionList = loanRepaymentTemplate.getPaymentTypeOptions(); // Sorting has to be done on the basis of // PaymentTypeOption.position because it is specified // by the users on Mifos X Platform. Collections.sort(paymentTypeOptionList); for (PaymentTypeOption paymentTypeOption : paymentTypeOptionList) { listOfPaymentTypes.add(paymentTypeOption.getName()); paymentTypeHashMap.put(paymentTypeOption.getName(), paymentTypeOption.getId()); } ArrayAdapter<String> paymentTypeAdapter = new ArrayAdapter<>(getActivity(), layout.simple_spinner_item, listOfPaymentTypes); paymentTypeAdapter.setDropDownViewResource(layout.simple_spinner_dropdown_item); sp_paymentType.setAdapter(paymentTypeAdapter); et_amount.setText(String.valueOf(loanRepaymentTemplate.getPrincipalPortion() + loanRepaymentTemplate.getInterestPortion())); et_additionalPayment.setText("0.0"); et_fees.setText(String.valueOf(loanRepaymentTemplate.getFeeChargesPortion())); } showProgress(false); } @Override public void failure(RetrofitError retrofitError) { showProgress(false); } }); }
From source file:com.hichinaschool.flashcards.anki.multimediacard.activity.TranslationActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (savedInstanceState != null) { boolean b = savedInstanceState.getBoolean(BUNDLE_KEY_SHUT_OFF, false); if (b) {/*from www . j a v a 2 s . co m*/ finishCancel(); return; } } setContentView(R.layout.activity_translation); try { mSource = getIntent().getExtras().getString(EXTRA_SOURCE).toString(); } catch (Exception e) { mSource = ""; } // If translation fails this is a default - source will be returned. mTranslation = mSource; LinearLayout linearLayout = (LinearLayout) findViewById(R.id.MainLayoutInTranslationActivity); TextView tv = new TextView(this); tv.setText(getText(R.string.multimedia_editor_trans_poweredglosbe)); linearLayout.addView(tv); TextView tvFrom = new TextView(this); tvFrom.setText(getText(R.string.multimedia_editor_trans_from)); linearLayout.addView(tvFrom); mLanguageLister = new LanguagesListerGlosbe(this); mSpinnerFrom = new Spinner(this); ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, mLanguageLister.getLanguages()); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mSpinnerFrom.setAdapter(adapter); linearLayout.addView(mSpinnerFrom); TextView tvTo = new TextView(this); tvTo.setText(getText(R.string.multimedia_editor_trans_to)); linearLayout.addView(tvTo); mSpinnerTo = new Spinner(this); ArrayAdapter<String> adapterTo = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, mLanguageLister.getLanguages()); adapterTo.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mSpinnerTo.setAdapter(adapterTo); linearLayout.addView(mSpinnerTo); Button btnDone = new Button(this); btnDone.setText(getText(R.string.multimedia_editor_trans_translate)); btnDone.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { translate(); } }); linearLayout.addView(btnDone); }
From source file:com.synchophy.ui.CoverFlowActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.coverflow);/* w w w . j a v a 2 s. co m*/ Spinner browseSpinner = (Spinner) this.findViewById(R.id.browseSpinner); ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, new String[] { "Covers", "Albums", "Artists" }); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); browseSpinner.setAdapter(adapter); ActivitySwipeDetector activitySwipeDetector = new ActivitySwipeDetector(this) { @Override public void onLeftToRightSwipe() { CoverFlowActivity.this.finish(); overridePendingTransition(R.anim.hold, R.anim.push_out_to_right); } @Override public void onBottomToTopSwipe() { showPlaylist(); } }; LinearLayout lowestLayout = (LinearLayout) this.findViewById(R.id.coverflowBack); lowestLayout.setOnTouchListener(activitySwipeDetector); coverFlow = (CoverFlow) findViewById(R.id.coverflow); coverFlow.setSpacing(-25); coverFlow.setSelection(4, true); coverFlow.setAnimationDuration(1000); registerForContextMenu(coverFlow); ImageAdapter coverImageAdapter = new ImageAdapter(CoverFlowActivity.this); coverFlow.setAdapter(coverImageAdapter); refresh(); }
From source file:ca.liquidlabs.android.speedtestvisualizer.activities.MapperActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // get feature to show progress in actionbar when processing data requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); setContentView(R.layout.activity_mapper); // It seems like 4.0.x enables progress by default - STOP it! hideProgressIndicator();//w w w . j a va 2 s . c o m Spinner spinner = (Spinner) findViewById(R.id.spinner_conntype_filter); ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.filters_array, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter); spinner.setOnItemSelectedListener(new ConnectionTypeFilterHandler()); // Show the Up button in the action bar. setupActionBar(); setUpMapIfNeeded(); }
From source file:com.dryver.Activities.ActivityDryverMain.java
/** * Assigns all UI elements to the actual views and instantiates adapters * * @see DryverMainAdapter/*from ww w. j a v a 2 s .co m*/ * @see ArrayAdapter */ private void assignElements() { sortSpinner = (Spinner) findViewById(R.id.requestSortSpinner); ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.activity_driver_spinner, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); sortSpinner.setAdapter(adapter); sortSpinner.setOnItemSelectedListener(this); searchByEditText = (EditText) findViewById(R.id.searchWith); searchButton = (Button) findViewById(R.id.searchButton); //TODO: Change this in future //sets the request singleton's requests lists to getAllRequests in ES Controller driverListView = (ListView) findViewById(R.id.dryverMainListView); //requestSingleton.setRequestsAll(); dryverMainAdapter = new DryverMainAdapter(this, requestSingleton.getRequests()); driverListView.setAdapter(dryverMainAdapter); }
From source file:com.adithya321.sharesanalysis.fragments.SharePurchaseFragment.java
@Nullable @Override//from w w w.j a v a 2 s .c o m public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_share_purchase, container, false); databaseHandler = new DatabaseHandler(getContext()); sharePurchasesRecyclerView = (RecyclerView) root.findViewById(R.id.share_purchases_recycler_view); emptyTV = (TextView) root.findViewById(R.id.empty); arrow = (ImageView) root.findViewById(R.id.arrow); setRecyclerViewAdapter(); FloatingActionButton addPurchaseFab = (FloatingActionButton) root.findViewById(R.id.add_purchase_fab); addPurchaseFab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { final Dialog dialog = new Dialog(getContext()); dialog.setTitle("Add Share Purchase"); dialog.setContentView(R.layout.dialog_add_share_purchase); dialog.getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.WRAP_CONTENT); dialog.show(); final AutoCompleteTextView name = (AutoCompleteTextView) dialog.findViewById(R.id.share_name); List<String> nseList = ShareUtils.getNseList(getContext()); FilterWithSpaceAdapter<String> arrayAdapter = new FilterWithSpaceAdapter<>(getContext(), android.R.layout.simple_dropdown_item_1line, nseList); name.setThreshold(1); name.setAdapter(arrayAdapter); final Spinner spinner = (Spinner) dialog.findViewById(R.id.existing_spinner); ArrayList<String> shares = new ArrayList<>(); for (Share share : sharesList) { shares.add(share.getName()); } ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<>(getContext(), android.R.layout.simple_spinner_item, shares); spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(spinnerAdapter); final RadioButton newRB = (RadioButton) dialog.findViewById(R.id.radioBtn_new); RadioButton existingRB = (RadioButton) dialog.findViewById(R.id.radioBtn_existing); if (shares.size() == 0) existingRB.setVisibility(View.GONE); (newRB).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { name.setVisibility(View.VISIBLE); spinner.setVisibility(View.GONE); } }); (existingRB).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { name.setVisibility(View.GONE); spinner.setVisibility(View.VISIBLE); } }); Calendar calendar = Calendar.getInstance(); year_start = calendar.get(Calendar.YEAR); month_start = calendar.get(Calendar.MONTH) + 1; day_start = calendar.get(Calendar.DAY_OF_MONTH); final Button selectDate = (Button) dialog.findViewById(R.id.select_date); selectDate.setText(new StringBuilder().append(day_start).append("/").append(month_start).append("/") .append(year_start)); selectDate.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Dialog dialog = new DatePickerDialog(getActivity(), onDateSetListener, year_start, month_start - 1, day_start); dialog.setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { selectDate.setText(new StringBuilder().append(day_start).append("/") .append(month_start).append("/").append(year_start)); } }); dialog.show(); } }); Button addPurchaseBtn = (Button) dialog.findViewById(R.id.add_purchase_btn); addPurchaseBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Share share = new Share(); share.setId(databaseHandler.getNextKey("share")); share.setPurchases(new RealmList<Purchase>()); Purchase purchase = new Purchase(); purchase.setId(databaseHandler.getNextKey("purchase")); if (newRB.isChecked()) { String sName = name.getText().toString().trim(); if (sName.equals("")) { Toast.makeText(getActivity(), "Invalid Name", Toast.LENGTH_SHORT).show(); return; } else { share.setName(sName); purchase.setName(sName); } } String stringStartDate = year_start + " " + month_start + " " + day_start; DateFormat format = new SimpleDateFormat("yyyy MM dd", Locale.ENGLISH); try { Date date = format.parse(stringStartDate); share.setDateOfInitialPurchase(date); purchase.setDate(date); } catch (Exception e) { Toast.makeText(getActivity(), "Invalid Date", Toast.LENGTH_SHORT).show(); return; } EditText quantity = (EditText) dialog.findViewById(R.id.no_of_shares); try { purchase.setQuantity(Integer.parseInt(quantity.getText().toString())); } catch (Exception e) { Toast.makeText(getActivity(), "Invalid Number of Shares", Toast.LENGTH_SHORT).show(); return; } EditText price = (EditText) dialog.findViewById(R.id.buying_price); try { purchase.setPrice(Double.parseDouble(price.getText().toString())); } catch (Exception e) { Toast.makeText(getActivity(), "Invalid Buying Price", Toast.LENGTH_SHORT).show(); return; } purchase.setType("buy"); if (newRB.isChecked()) { if (!databaseHandler.addShare(share, purchase)) { Toast.makeText(getActivity(), "Share Already Exists", Toast.LENGTH_SHORT).show(); return; } } else { purchase.setName(spinner.getSelectedItem().toString()); databaseHandler.addPurchase(spinner.getSelectedItem().toString(), purchase); } setRecyclerViewAdapter(); dialog.dismiss(); } }); } }); return root; }
From source file:com.h6ah4i.android.example.openslmediaplayer.app.contents.HQVisualizerFragment.java
private void setupViews() { HQVisualizerStateStore state = getStateStore(); Context context = getActivity(); mDuringSetupViews = true;/*ww w .j av a 2 s .co m*/ mToggleButtonEnableWaveform.setChecked(state.isCaptureWaveformEnabled()); mToggleButtonEnableFft.setChecked(state.isCaptureFftEnabled()); { final ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(context, R.array.hq_visualizer_window_type_names, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mSpinnerWindowType.setAdapter(adapter); } mSpinnerWindowType.setSelection(windowTypeToListPosition(state.getWindowType())); mDuringSetupViews = false; }
From source file:com.mifos.mifosxdroid.online.SavingsAccountFragment.java
private void inflateInterestCalculationTypeSpinner() { final ArrayList<String> interestCalculationTypeNames = filterListObject( savingproductstemplate.getInterestCalculationTypeOptions()); final ArrayAdapter<String> interestCalculationTypeAdapter = new ArrayAdapter<>(getActivity(), layout.simple_spinner_item, interestCalculationTypeNames); interestCalculationTypeAdapter.setDropDownViewResource(layout.simple_spinner_dropdown_item); sp_interest_calc.setAdapter(interestCalculationTypeAdapter); sp_interest_calc.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override// w w w.ja v a 2 s .c o m public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { interestCalculationTypeAdapterId = savingproductstemplate.getInterestCalculationTypeOptions().get(i) .getId(); Log.d("interestCalculation " + interestCalculationTypeNames.get(i), String.valueOf(interestCalculationTypeAdapterId)); if (interestCalculationTypeAdapterId != -1) { } else { Toast.makeText(getActivity(), getString(R.string.error_select_office), Toast.LENGTH_SHORT) .show(); } } @Override public void onNothingSelected(AdapterView<?> parent) { } }); }
From source file:fr.eoit.activity.ParameterActivity.java
private void refreshCharacterSpinner() { charactersXMLParser = new CharactersXmlParser(new AndroidUrlDownloader(), Xml.newPullParser(), Parameters.keyId, Parameters.vCode); characterSpinner = (Spinner) findViewById(R.id.CHARACTER_SPINNER); if (Parameters.vCode != null && Parameters.vCode.length() > 0) { new LoadCharacterSpinnerAsyncTask().execute((Void[]) null); } else {//from w ww. j a v a2 s . c o m charactersXMLParser.resetCharacterMap(); ArrayAdapter<String> adapter = new ArrayAdapter<String>(getApplicationContext(), android.R.layout.simple_spinner_item, new String[] { getString(R.string.all_level_v) }); adapter.setDropDownViewResource(android.R.layout.simple_dropdown_item_1line); characterSpinner.setAdapter(adapter); characterSpinner.setOnItemSelectedListener(null); } }