@Override protected void onResume() { super.onResume(); String[] names_of = fileList(); //arr.length int name_size = names_of.length; not=(LinearLayout)findViewById(R.id.not); ListView names = (ListView)findViewById(R.id.LIST); ArrayAdapter<String> nameAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, names_of); if (names_of.length<1){ not.setVisibility(View.VISIBLE); names.setVisibility(View.GONE); }else { not.setVisibility(View.GONE); names.setVisibility(View.VISIBLE); } names.setAdapter(nameAdapter); }
private void initPowerRankings(List<Profile> profiles){ powerList = (ListView)findViewById(R.id.rankingsPowerList); List<String> elements = new ArrayList<>(); // compare based on points, in descending order Collections.sort(profiles, new Comparator<Profile>() { @Override public int compare(Profile p1, Profile p2) { Integer lhsPoints = p1.getPowerPoints(); Integer rhsPoints = p2.getPowerPoints(); return -1 * lhsPoints.compareTo(rhsPoints); } }); int rank = 1; for (Profile profile : profiles){ int points = profile.getPowerPoints(); elements.add(rank + ": " + profile.getName() + ": " + points); ++rank; } ArrayAdapter<String> adapter = new ArrayAdapter<>(this, R.layout.list_item, elements); powerList.setAdapter(adapter); }
private void initOverallRankings(List<Profile> profiles){ overallList = (ListView)findViewById(R.id.rankingsList); List<String> elements = new ArrayList<>(); // compare based on points, in descending order Collections.sort(profiles, new Comparator<Profile>() { @Override public int compare(Profile p1, Profile p2) { Integer lhsPoints = p1.getHabitPoints(); Integer rhsPoints = p2.getHabitPoints(); return -1 * lhsPoints.compareTo(rhsPoints); } }); int rank = 1; for (Profile profile : profiles){ int points = profile.getHabitPoints(); elements.add(rank + ": " + profile.getName() + ": " + points); ++rank; } ArrayAdapter<String> adapter = new ArrayAdapter<>(this, R.layout.list_item, elements); overallList.setAdapter(adapter); }
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main, container, false); String forecastArray[] = {}; FetchWeatherTask weatherTask = new FetchWeatherTask(); weatherTask.execute(); List<String> weekForecast = new ArrayList(Arrays.asList(forecastArray)); mForeCastAdapter = new ArrayAdapter<String>( getActivity(), R.layout.list_item_forecast, R.id.list_item_forecast_textview, weekForecast); ListView listview = (ListView) rootView.findViewById(R.id.listview_forecast); listview.setAdapter(mForeCastAdapter); return rootView; }
protected void initSpecificControls() { initSpnUomFuel(); //setup bpartner adapter mBPartnerAdapter = null; if (getActivity() != null) { String[] entries = mDbAdapter.getAutoCompleteText(DBAdapter.TABLE_NAME_BPARTNER, null, "WHERE " + DB.COL_NAME_GEN_ISACTIVE + " = 'Y' " + " AND LENGTH(TRIM(" + DB.COL_NAME_GEN_NAME + ")) > 0 " + " AND " + DB.COL_NAME_BPARTNER__ISGASSTATION + " = 'Y'", 0, 0); if (entries != null) { mBPartnerAdapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_list_item_1, entries); } acBPartner.setAdapter(mBPartnerAdapter); } }
public void initListPop() { listPopupWindow = new ListPopupWindow(getContext()); ArrayAdapter arrayAdapter = new ArrayAdapter(getContext(), R.layout.item_list_pop, cardTemplateList); listPopupWindow.setAdapter(arrayAdapter); listPopupWindow.setWidth(RelativeLayout.LayoutParams.WRAP_CONTENT); listPopupWindow.setHeight(RelativeLayout.LayoutParams.WRAP_CONTENT); listPopupWindow.setAnchorView(mCardTemplate); listPopupWindow.setModal(true); listPopupWindow.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { mCardTemplate.setText(cardTemplateList.get(position)); if ("2".equals(sparseArray.get(position).key)) {//虚拟卡 setEnabledStatus(false); } else { setEnabledStatus(true); } cardTemplateId = sparseArray.get(position).key; listPopupWindow.dismiss(); } }); }
private void updateAyahSpinner(QuranSpinner spinner, ArrayAdapter<CharSequence> adapter, int maxAyah, int currentAyah) { final Context context = getActivity(); if (context != null) { CharSequence[] ayahs = new String[maxAyah]; for (int i = 0; i < maxAyah; i++) { ayahs[i] = QuranUtils.getLocalizedNumber(context, (i + 1)); } adapter.clear(); for (int i = 0; i < maxAyah; i++) { adapter.add(ayahs[i]); } spinner.setSelection(currentAyah - 1); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.item_dialog); setCanceledOnTouchOutside(true); tvItemDialogTitle = (TextView) findViewById(R.id.tvItemDialogTitle); lvItemDialog = (ListView) findViewById(R.id.lvItemDialog); tvItemDialogTitle.setVisibility(StringUtil.isNotEmpty(title, true) ? View.VISIBLE : View.GONE); tvItemDialogTitle.setText("" + StringUtil.getCurrentString()); adapter = new ArrayAdapter<String>(context, R.layout.item_dialog_item, items); lvItemDialog.setAdapter(adapter); lvItemDialog.setOnItemClickListener(this); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_division); Bundle dataBundle = getIntent().getExtras(); Data data = (Data) dataBundle.getSerializable("data"); String div_name = dataBundle.getString("div"); bg = (ImageView) findViewById(R.id.division_image); placeList = (ListView) findViewById(R.id.place_list); divisionName = (TextView) findViewById(R.id.division_name); divisionName.setText(data.getDivisionName(div_name)); bg.setImageResource(data.getImageRes(div_name)); System.out.println(data.getPlaces(div_name)); ArrayAdapter<String> adapter = new ArrayAdapter<String> (DivisionActivity.this, android.R.layout.simple_list_item_1, data.getPlaces(div_name)); placeList.setAdapter(adapter); }
private static void displayListViewDialog(@NonNull Context context, @NonNull String title, @NonNull ArrayList<String> list) { final android.app.Dialog dialog = new android.app.Dialog(context); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.dialog_listview); TextView titleView = dialog.findViewById(R.id.dialog_title_text_view); titleView.setText(title); com.rey.material.widget.Button closeButton = dialog.findViewById(R.id.dialog_button_close); closeButton.setOnClickListener(v -> dialog.dismiss()); ListView listView = dialog.findViewById(R.id.dialog_list_view); listView.setAdapter(new ArrayAdapter<>(context, android.R.layout.simple_dropdown_item_1line, list)); dialog.setCancelable(true); dialog.show(); Window window = dialog.getWindow(); if (window != null) { window.setLayout(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); } }
@Override public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) { ArrayAdapter adapter = (ArrayAdapter) getAdapter(); if (null != adapter) { if (_items.size() == 0) { for (int i = 0; i < adapter.getCount(); i++) { _items.add(adapter.getItem(i)); } } SearchableListDialog searchableListDialog = SearchableListDialog.newInstance (_items); searchableListDialog.setOnSearchableItemClickListener(this); searchableListDialog.show(((Activity) _context).getFragmentManager(), "TAG"); } } return true; }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ListView listView = (ListView) findViewById(R.id.list); listView.setOnItemClickListener(this); ArrayAdapter<String> demoAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1); for (Demo demo : Demo.values()) { demoAdapter.add(getString(demo.titleResId)); } listView.setAdapter(demoAdapter); }
/** * @see {@link Activity#onCreate} */ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_open_api_base_layout); // 获取功能列表 mFuncList = getResources().getStringArray(R.array.statuses_func_list); // 初始化功能列表 ListView mFuncListView = (ListView)findViewById(R.id.api_func_list); mFuncListView.setAdapter(new ArrayAdapter<String>( this, android.R.layout.simple_list_item_1, mFuncList)); mFuncListView.setOnItemClickListener(this); // 获取当前已保存过的 Token mAccessToken = AccessTokenKeeper.readAccessToken(this); // 对statusAPI实例化 mStatusesAPI = new StatusesAPI(this, Constants.APP_KEY, mAccessToken); }
public BitmapAnimationCacheSelectorConfigurator( Spinner spinner, BitmapFrameCacheChangedListener bitmapFrameCacheChangedListener, BitmapFrameCache.FrameCacheListener frameCacheListener) { mSpinner = spinner; mBitmapFrameCacheChangedListener = bitmapFrameCacheChangedListener; mFrameCacheListener = frameCacheListener; mContext = mSpinner.getContext(); mArrayAdapter = new ArrayAdapter<>(spinner.getContext(), android.R.layout.simple_spinner_item); mArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mSpinner.setAdapter(mArrayAdapter); addSampleBackends(); setupSelector(); }
/** * Load voice settings from file and set radio buttons * @throws IOException * @throws XmlPullParserException */ private void loadData() throws IOException, XmlPullParserException { ArrayMap<String, String> values = settingsManager.getSettings(); voice = values.get("id"); Voice loadedVoice = searchVoice(voice); if(loadedVoice == null){ Toast.makeText(getContext(), "Errore caricamento impostazioni", Toast.LENGTH_SHORT).show(); return; } // Language/Locale language = loadedVoice.get("locale"); spnLanguage.setSelection(((ArrayAdapter) spnLanguage.getAdapter()).getPosition(language)); // Gender gender = loadedVoice.get("gender"); if(gender.equals("male")) rbM.setChecked(true); else rbF.setChecked(true); updateChoice(); // Voice int pos=((ArrayAdapter) spnVoice.getAdapter()).getPosition(voice); spnVoice.setSelection(pos); // Speed speed = Float.valueOf(values.get("speed")); spnSpeed.setSelection(Math.round((speed - 1) / 0.25f)); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_found_view); final TextView found_view_back = (TextView) findViewById(R.id.found_view_back); final ListView found_view_list = (ListView) findViewById(R.id.found_view_list); // Animation animation = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.fade_out); ArrayAdapter<String> adapter = new ArrayAdapter(this, android.R.layout.simple_spinner_item, displayFoundItem()); found_view_list.setAdapter(adapter); final Animation fade_in_anim = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.fade_in); found_view_list.setAnimation(fade_in_anim); found_view_back.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { goToMain(); } }); }
@Override public void onActivityCreated(@Nullable Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); viewModel = ViewModelProviders.of(getActivity()).get(MainActivityViewModel.class); viewModel.listOfCities().observe(this, cities -> { if (cities == null) cities = Collections.emptyList(); ArrayAdapter<String> adapter = new ArrayAdapter<>(this.getContext(), android.R.layout.simple_list_item_1, cities); cityList.setAdapter(adapter); }); cityList.setOnItemClickListener((parent, view, position, id) -> { String cityName = (String) parent.getItemAtPosition(position); viewModel.selectCity(cityName); }); }
public void initList(List<SwitchVideoModel> data, OnListItemClickListener onItemClickListener) { this.onItemClickListener = onItemClickListener; this.data = data; LayoutInflater inflater = LayoutInflater.from(mContext); View view = inflater.inflate(R.layout.switch_video_dialog, null); listView = (ListView) view.findViewById(R.id.switch_dialog_list); setContentView(view); adapter = new ArrayAdapter<>(mContext, R.layout.switch_video_dialog_item, data); listView.setAdapter(adapter); listView.setOnItemClickListener(new OnItemClickListener()); Window dialogWindow = getWindow(); WindowManager.LayoutParams lp = dialogWindow.getAttributes(); DisplayMetrics d = mContext.getResources().getDisplayMetrics(); // 获取屏幕宽、高用 lp.width = (int) (d.widthPixels * 0.8); // 高度设置为屏幕的0.6 dialogWindow.setAttributes(lp); }
@SuppressWarnings("unchecked") public void refreshCollections() { ArrayAdapter<TGSelectableItem> arrayAdapter = new ArrayAdapter<TGSelectableItem>(findActivity(), R.layout.view_browser_spinner_item, createCollectionValues()); arrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); TGSelectableItem selectedItem = new TGSelectableItem(findCurrentCollection(), null); Integer selectedItemPosition = arrayAdapter.getPosition(selectedItem); Spinner spinner = (Spinner) this.findViewById(R.id.browser_collections); OnItemSelectedListener listener = spinner.getOnItemSelectedListener(); spinner.setOnItemSelectedListener(null); if(!this.isSameCollection(arrayAdapter, (ArrayAdapter<TGSelectableItem>) spinner.getAdapter())) { spinner.setAdapter(arrayAdapter); } if( spinner.getSelectedItemPosition() != selectedItemPosition ) { spinner.setSelection(selectedItemPosition, false); } spinner.setOnItemSelectedListener(listener); }
private void fillBkList() { bkFileList = FileUtils.listBkFiles(this, false); if (bkFileList == null || bkFileList.isEmpty()) { // btnRestore.setEnabled(false); lvBackupList.setAdapter(null); return; } ArrayAdapter<String> listAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_single_choice, bkFileList); lvBackupList.setAdapter(listAdapter); lvBackupList.setItemsCanFocus(false); lvBackupList.setChoiceMode(ListView.CHOICE_MODE_SINGLE); lvBackupList.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { selectedFile = bkFileList.get(i); //show the delete option mAppMenu.setGroupVisible(R.id.mnu_backup_list, true); } }); }
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.choose_area, container, false); // 设置系统状态栏高度 View statusBar = view.findViewById(R.id.status_bar); ViewGroup.LayoutParams layoutParams = statusBar.getLayoutParams(); layoutParams.height = getStatusBarHeight(); if (getActivity() instanceof MainActivity) { statusBar.setVisibility(View.GONE); } else { statusBar.setVisibility(View.VISIBLE); } titleText = (TextView) view.findViewById(R.id.title_text); backButton = (Button) view.findViewById(R.id.back_button); listView = (ListView) view.findViewById(R.id.list_view); adapter = new ArrayAdapter<>(getContext(), android.R.layout.simple_list_item_1, dataList); listView.setAdapter(adapter); return view; }
void initAdapter(List<String> skins) { final Context context = mListView.getContext(); mAdapter = new ArrayAdapter<String>(context, -1, skins) { @Override public View getView(int position, View convertView, ViewGroup parent) { if (convertView == null) { convertView = SkinManager.getInstance().getResources().getView(context, R.layout.item); } TextView tv = (TextView) convertView.findViewById(R.id.id_tv_title); String path = getItem(position); tv.setText(new File(path).getName()); return convertView; } }; mListView.setAdapter(mAdapter); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_choose_area); backButton = (Button) findViewById(R.id.back_button); areaName = (TextView) findViewById(R.id.area_name); listView = (ListView) findViewById(R.id.list_view); progressBar = (ProgressBar) findViewById(R.id.progress_bar); mAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, dataList); listView.setAdapter(mAdapter); listView.setOnItemClickListener(this); backButton.setOnClickListener(this); showProvinceList(); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_listview); mAutoScrollPagerAdapter = new BannerAdapter(this, 3, true); mListView = (ListView) findViewById(R.id.listview); mSwipeRefreshLayout = (CustomSwipeRefreshLayout) findViewById(R.id.swiperefresh_layout); // AutoScrollViewPager header View headerView = LayoutInflater.from(this).inflate(R.layout.list_header, mListView, false); mAutoScrollViewPager = (CycleViewPager) headerView.findViewById(R.id.banner); mIndicator = (ViewPagerIndicator) headerView.findViewById(R.id.viewpager_indicator); mListView.addHeaderView(headerView); // mAutoScrollViewPager.setPageSwitchDuration(800); // mAutoScrollViewPager.setAutoScrollInterval(4000); mListView.setAdapter(new ArrayAdapter<String>(WorkInListViewActivity.this, android.R.layout.simple_list_item_1, android.R.id.text1, getData())); mAutoScrollViewPager.setAdapter(mAutoScrollPagerAdapter); mIndicator.bindToViewPager(mAutoScrollViewPager); mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { WorkInListViewActivity.this.onRefresh(); } }); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); try { mAssetFileList = filterHtmlFile(AssetsUtils.allFiles(this)).toArray(); ListView listView = new ListView(this); ArrayAdapter<Object> arrayAdapter = new ArrayAdapter<>(this, R.layout .example_list_item, R.id.example_list_title, mAssetFileList); listView.setAdapter(arrayAdapter); listView.setOnItemClickListener(this); setContentView(listView); } catch (IOException e) { } }
private void addEmailsToAutoComplete(List<String> emailAddressCollection) { //Create adapter to tell the AutoCompleteTextView what to show in its dropdown list. ArrayAdapter<String> adapter = new ArrayAdapter<>(LoginActivity.this, android.R.layout.simple_dropdown_item_1line, emailAddressCollection); mEmailView.setAdapter(adapter); }
private void initFontFamilySpinner(String familyName) { Spinner spinner = (Spinner) findViewById(R.id.edit_font_family); spinner.setOnItemSelectedListener(this); mFontFamilySet = new FontFamilySet(); mSelectedFontFamily = mFontFamilySet.getFontFamily(familyName); mFontFamilyNameList = mFontFamilySet.getFontFamilyDisplayNameList(); spinner.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_spinner_dropdown_item, mFontFamilyNameList)); spinner.setSelection(mFontFamilyNameList.indexOf(mSelectedFontFamily.displayName)); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_send_message); Spinner spinner = (Spinner) findViewById(R.id.spinner); // Create an ArrayAdapter using the string array and a default spinner layout ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.spinner_array, 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); }
private void refreshSpinner() { mSpinnerOptionUUIDs = new ArrayList<>(); List<String> options = new ArrayList<>(); options.add(mServerSpinner.getContext().getString(R.string.value_any)); mSpinnerOptionUUIDs.add(null); for (ServerConfigData data : ServerConfigManager.getInstance(mServerSpinner.getContext()).getServers()) { options.add(data.name); mSpinnerOptionUUIDs.add(data.uuid); } ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<>(mServerSpinner.getContext(), R.layout.simple_spinner_item, android.R.id.text1, options); spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mServerSpinner.setAdapter(spinnerAdapter); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_dashboard); usernameText = (TextView) findViewById(R.id.profile_username); emailText = (TextView) findViewById(R.id.profile_email); tokenStore = new TokenStore(this); if (new AuthenticationManager(this).isAuthenticated()) { // add some fake user entries ListView listView = (ListView) findViewById(R.id.dashboard_entries); listView.setAdapter(new ArrayAdapter<>( this, android.R.layout.simple_list_item_1, new String[] {"Entry 1"})); // button to retrieve user profile Button profileButton = (Button) findViewById(R.id.profile_button); profileButton.setOnClickListener(this); } else { Intent loginIntent = new Intent(this, MainActivity.class); startActivity(loginIntent); finish(); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ListView sampleList = (ListView) findViewById(R.id.sample_list); sampleList.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,getResources().getStringArray(R.array.list_name))); sampleList.setOnItemClickListener(this); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_config_sync); volumeName = (EditText) findViewById(R.id.volumeName); //volumeName.setFocusable(false); volumePath = (EditText) findViewById(R.id.volumePath); //volumePath.setFocusable(false); password = (EditText) findViewById(R.id.volumePassword); password.setTransformationMethod(PasswordTransformationMethod.getInstance()); password.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); onlyWifiCheckBox = ((CheckBox) findViewById(R.id.onlyWifi)); removeAfterCheckBox = ((CheckBox) findViewById(R.id.removeAfter)); localFolder = ((EditText) findViewById(R.id.localFolder)); syncID = ((EditText) findViewById(R.id.syncID)); syncID.setFocusable(false); spin1=(Spinner) findViewById(R.id.selectedRule); ArrayAdapter<String> adapter=new ArrayAdapter<String>(ConfigSyncActivity.this, android.R.layout.simple_spinner_item, rules); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spin1.setAdapter(adapter); spin1.setOnTouchListener(this); spin1.setOnItemSelectedListener((OnItemSelectedListener) this); refresh(null); }
public MainPresentImpl(Context context, IMainView mainView) { this.context = context; this.mainView = mainView; if (adapter == null) adapter = new ArrayAdapter<>(context, android.R.layout.simple_list_item_1, new String[] { "SDK.getInstance().init();", "SDK.getInstance().search(key);", }); }
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); lvDrawer = (ListView) findViewById(R.id.left_drawer); lvDrawer.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_list_item_1 , getTitleMenus())); lvDrawer.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { } }); }
@Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); categorySpinnerAdapter = new ArrayAdapter<>(getActivity(), R.layout.support_simple_spinner_dropdown_item, new ArrayList<>()); categoriesSpinner.setAdapter(categorySpinnerAdapter); ArrayAdapter<String> difficultySpinnerAdapter = new ArrayAdapter<>(getActivity(), R.layout.support_simple_spinner_dropdown_item, difficulties); difficultiesSpinner.setAdapter(difficultySpinnerAdapter); ArrayAdapter<String> gameTypeSpinnerAdapter = new ArrayAdapter<>(getActivity(), R.layout.support_simple_spinner_dropdown_item, gameTypes); gameTypesSpinner.setAdapter(gameTypeSpinnerAdapter); ArrayAdapter<String> amountsSpinnerAdapter = new ArrayAdapter<>(getActivity(), R.layout.support_simple_spinner_dropdown_item, amounts); amountsSpinner.setAdapter(amountsSpinnerAdapter); presenter.subscribe(savedInstanceState != null ? Parcels.unwrap( savedInstanceState.getParcelable(MainState.CATEGORY_STATE_KEY)) : null); categoriesSpinner.setSelection( savedInstanceState != null ? savedInstanceState.getInt(CATEGORIES_POSITION_KEY) : 0); difficultiesSpinner.setSelection( savedInstanceState != null ? savedInstanceState.getInt(DIFFICULTIES_POSITION_KEY) : 0); gameTypesSpinner.setSelection( savedInstanceState != null ? savedInstanceState.getInt(GAMETYPE_POSITION_KEY) : 0); amountsSpinner.setSelection( savedInstanceState != null ? savedInstanceState.getInt(GAMETYPE_POSITION_KEY) : 0); }
private void setupSpinner() { Spinner spinner = findViewById(R.id.spinner); spinner.setOnItemSelectedListener(mMainItemSelected); List<String> categories = new ArrayList<>(); categories.add("All"); categories.add("Photos"); categories.add("Videos"); ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, categories); dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(dataAdapter); Spinner spinnerFilter = findViewById(R.id.spinnerFilter); spinnerFilter.setOnItemSelectedListener(mFilterItemSelected); List<String> filter = new ArrayList<>(); filter.add("CLUSTER BY ALBUM"); filter.add("CLUSTER BY TIME"); filter.add("CLUSTER BY LOCATION"); filter.add("CLUSTER BY TAG"); filter.add("CLUSTER BY SIZE"); filter.add("CLUSTER BY FACE"); ArrayAdapter<String> dataAdapterFilter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, filter); dataAdapterFilter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinnerFilter.setAdapter(dataAdapterFilter); }
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { if (parent.equals(spMonth)) { spDay.setAdapter(new ArrayAdapter<String>(this, R.layout.view_spinner, getDays(position + 1))); spDay.setSelection(Integer.parseInt(currentDay) - 1); } else if (parent.equals(spDay)) { currentDay = Integer.toString(position + 1); String date = "" + spMonth.getSelectedItem() + spDay.getSelectedItem(); api.queryHistory(date, this); } }
private void initListPopupIfNeed() { if (mListPopup == null) { String[] listItems = new String[]{ "Item 1", "Item 2", "Item 3", "Item 4", "Item 5", }; List<String> data = new ArrayList<>(); Collections.addAll(data, listItems); ArrayAdapter adapter = new ArrayAdapter<>(getActivity(), R.layout.simple_list_item, data); mListPopup = new QMUIListPopup(getContext(), QMUIPopup.DIRECTION_NONE, adapter); mListPopup.create(QMUIDisplayHelper.dp2px(getContext(), 250), QMUIDisplayHelper.dp2px(getContext(), 200), new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { Toast.makeText(getActivity(), "Item " + (i + 1), Toast.LENGTH_SHORT).show(); mListPopup.dismiss(); } }); mListPopup.setOnDismissListener(new PopupWindow.OnDismissListener() { @Override public void onDismiss() { mActionButton2.setText(getContext().getResources().getString(R.string.popup_list_action_button_text_show)); } }); } }
private void addSpinnerItems(Spinner spinner, LocalizableEnum[] a) { int length = a.length; SpinnerItem[] items = new SpinnerItem[length]; for (int i=0; i<length; i++) { LocalizableEnum x = a[i]; String title = getString(x.getTitleId()); String value = x.name(); items[i] = new SpinnerItem(title, value); } ArrayAdapter<SpinnerItem> adapter = new ArrayAdapter<SpinnerItem>(this, android.R.layout.simple_spinner_item, items); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter); }