android.widget.ArrayAdapter Java Examples
The following examples show how to use
android.widget.ArrayAdapter.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AsyncNavigationAdapter.java From rss with GNU General Public License v3.0 | 7 votes |
@Override protected void onPostExecute(String[][] result) { // Set the titles & counts arrays in this file and notify the adapter. ListView navigationList = (ListView) m_activity.findViewById(R.id.fragment_navigation_drawer); WrapperListAdapter wrapperAdapter = (WrapperListAdapter) navigationList.getAdapter(); ArrayAdapter<String[]> adapter = (ArrayAdapter<String[]>) wrapperAdapter.getWrappedAdapter(); // Update the data in the adapter. adapter.clear(); adapter.addAll(result); // Update the subtitle. if(Constants.s_fragmentFeeds.isVisible()) { Utilities.setTitlesAndDrawerAndPage(null, -10); } }
Example #2
Source File: GOneToManyConnectedComboView.java From geopaparazzi with GNU General Public License v3.0 | 6 votes |
@Override public void onItemSelected(AdapterView<?> parent, View callingView, int pos, long arg3) { if (parent == mainComboSpinner) { String mainComboItem = mainComboSpinner.getSelectedItem().toString(); List<NamedList<String>> namedLists = new ArrayList<>(); if (mainComboItem.length() != 0) { namedLists = dataMap.get(mainComboItem); } for (int i = 0; i < namedLists.size(); i++) { NamedList<String> namedList = namedLists.get(i); TextView subTextView = orderedSubTextviewsList.get(i); subTextView.setText(namedList.name); Spinner subSpinner = orderedSubCombosList.get(i); ArrayAdapter<String> combo2ListAdapter = new ArrayAdapter<String>(parent.getContext(), android.R.layout.simple_spinner_dropdown_item, namedList.items); combo2ListAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); subSpinner.setAdapter(combo2ListAdapter); } } }
Example #3
Source File: ExpandableListView.java From ExpandableHeightListView with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_expandable_list_view); ArrayList<Integer> numbersArray = new ArrayList<Integer>(); ExpandableHeightListView expandableListView = (ExpandableHeightListView) findViewById(R.id.expandable_listview); int i; for (i=0; i<=20; i++){ numbersArray.add(i); } ArrayAdapter<Integer> itemsAdapter = new ArrayAdapter<Integer>(this, android.R.layout.simple_list_item_1, numbersArray); expandableListView.setAdapter(itemsAdapter); // This actually do the magic expandableListView.setExpanded(true); }
Example #4
Source File: MainActivity.java From android-Notifications with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mMainRelativeLayout = (RelativeLayout) findViewById(R.id.mainRelativeLayout); mNotificationDetailsTextView = (TextView) findViewById(R.id.notificationDetails); mSpinner = (Spinner) findViewById(R.id.spinner); mNotificationManagerCompat = NotificationManagerCompat.from(getApplicationContext()); // Create an ArrayAdapter using the string array and a default spinner layout. ArrayAdapter<CharSequence> adapter = new ArrayAdapter( this, android.R.layout.simple_spinner_item, NOTIFICATION_STYLES); // 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. mSpinner.setAdapter(adapter); mSpinner.setOnItemSelectedListener(this); }
Example #5
Source File: ListViewActivity.java From FadingActionBar with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); FadingActionBarHelper helper = new FadingActionBarHelper() .actionBarBackground(R.drawable.ab_background) .headerLayout(R.layout.header) .contentLayout(R.layout.activity_listview); setContentView(helper.createView(this)); helper.initActionBar(this); ListView listView = (ListView) findViewById(android.R.id.list); ArrayList<String> items = loadItems(R.raw.nyc_sites); adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, items); listView.setAdapter(adapter); }
Example #6
Source File: MainActivity.java From sensordatacollector with GNU General Public License v2.0 | 6 votes |
public void refreshActivityScreenPosture(final String posture) { runOnUiThread(new Runnable() { @Override public void run() { @SuppressWarnings( "unchecked" ) // it is save ArrayAdapter<String> postureAdapter = (ArrayAdapter<String>) AdapterController.getInstance().get("ActivityScreenPosture"); if(postureAdapter == null) { return; } postureAdapter.clear(); postureAdapter.add(posture); postureAdapter.notifyDataSetChanged(); } }); }
Example #7
Source File: WifiSkillViewFragment.java From Easer with GNU General Public License v3.0 | 6 votes |
private void onResultsAvailable() { wait_lock.lock(); try { if (!waiting_for_result) return; waiting_for_result = false; } finally { wait_lock.unlock(); } final ArrayAdapter<WifiConfigurationWrapper> arrayAdapter = new ArrayAdapter<>(getContext(), android.R.layout.select_dialog_singlechoice); for (WifiConfigurationWrapper wrapper : obtainWifiList()) { arrayAdapter.add(wrapper); } AlertDialog.Builder builderSingle = new AlertDialog.Builder(getContext()); builderSingle.setTitle(R.string.usource_wificonn_select_dialog_title); builderSingle.setAdapter(arrayAdapter, new DialogInterface.OnClickListener() { @SuppressWarnings("ConstantConditions") @Override public void onClick(DialogInterface dialog, int which) { onWifiSelected(arrayAdapter.getItem(which)); } }); builderSingle.show(); progressDialog.dismiss(); }
Example #8
Source File: GalleryDetailScene.java From EhViewer with Apache License 2.0 | 6 votes |
private void bind(Pair<String, String>[] data) { if (null == mDialog || null == mProgressView || null == mErrorText || null == mListView) { return; } if (0 == data.length) { mProgressView.setVisibility(View.GONE); mErrorText.setVisibility(View.VISIBLE); mListView.setVisibility(View.GONE); mErrorText.setText(R.string.no_archives); } else { String[] nameArray = new String[data.length]; for (int i = 0, n = data.length; i < n; i++) { nameArray[i] = data[i].second; } mProgressView.setVisibility(View.GONE); mErrorText.setVisibility(View.GONE); mListView.setVisibility(View.VISIBLE); mListView.setAdapter(new ArrayAdapter<>(mDialog.getContext(), R.layout.item_select_dialog, nameArray)); } }
Example #9
Source File: PreferenceFragment.java From habpanelviewer with GNU General Public License v3.0 | 6 votes |
@Override public void validationAvailable(List<String> items) { mUiHandler.post(() -> { List<Preference> list = getPreferenceList(getPreferenceScreen(), new ArrayList<>()); for (Preference p : list) { if (p.getKey().endsWith(Constants.PREF_SUFFIX_ITEM) && p instanceof EditTextPreference) { final EditText editText = ((EditTextPreference) p).getEditText(); if (editText instanceof AutoCompleteTextView) { AutoCompleteTextView t = (AutoCompleteTextView) editText; t.setAdapter(new ArrayAdapter<>(getActivity(), android.R.layout.simple_dropdown_item_1line, items)); t.performValidation(); } } } }); }
Example #10
Source File: CountActivity.java From accountBook with Apache License 2.0 | 6 votes |
/** * 初始化spinner */ private void initSpinner(){ month_spinner = (Spinner) findViewById(R.id.month_spinner); //将可选内容与ArrayAdapter连接起来 month_adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, monthList); //设置下拉列表的风格 month_adapter .setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); //将adapter添加到spinner中 month_spinner.setAdapter(month_adapter); //添加事件Spinner事件监听 month_spinner .setOnItemSelectedListener(new month_spinnerSelectedListener()); //设置默认值 month_spinner.setSelection(pubFun.getTime("M"), true); month_spinner.setVisibility(View.VISIBLE); }
Example #11
Source File: ActivityPublishData.java From gsn with GNU General Public License v3.0 | 6 votes |
public void renderVSList() { new AsyncTask<AndroidControllerPublish, Void, ArrayList<String>>() { @Override protected ArrayList<String> doInBackground(AndroidControllerPublish... params) { return params[0].loadListVS(); } @Override protected void onPostExecute(ArrayList<String> result) { ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(ActivityPublishData.this, R.layout.spinner_item, result); dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); vsnameSpinner.setAdapter(dataAdapter); if (dr != null) { int p = dataAdapter.getPosition(dr.getVsname()); if (p != -1) { vsnameSpinner.setSelection(p); } } } }.execute(controller); }
Example #12
Source File: DetailActivity.java From KinoCast with MIT License | 6 votes |
private void setMirrorSpinner(Host mirrors[]) { if (mirrors != null && mirrors.length > 0) { Arrays.sort(mirrors, new WeightedHostComparator(Utils.getWeightedHostList(getApplicationContext()))); ((Spinner) findViewById(R.id.spinnerMirror)).setAdapter( new ArrayAdapter<>(DetailActivity.this, android.R.layout.simple_list_item_1, mirrors)); findViewById(R.id.spinnerMirror).setEnabled(true); findViewById(R.id.buttonPlay).setEnabled(true); } else { ((Spinner) findViewById(R.id.spinnerMirror)).setAdapter( new ArrayAdapter<>(DetailActivity.this, android.R.layout.simple_list_item_1, new String[]{getString(R.string.no_host_found)})); findViewById(R.id.spinnerMirror).setEnabled(false); findViewById(R.id.buttonPlay).setEnabled(false); } findViewById(R.id.layoutMirror).setVisibility(View.VISIBLE); }
Example #13
Source File: Fragment0.java From PullRefreshView with Apache License 2.0 | 6 votes |
@Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { view = inflater.inflate(R.layout.fragment0, container, false); listView = findViewById(R.id.list); headerView = findViewById(R.id.header); footerView = findViewById(R.id.footer); list = getData(15); adapter = new ArrayAdapter(getContext(), R.layout.item, list); listView.setAdapter(adapter); headerView.setOnRefreshListener(this); footerView.setOnLoadListener(this); return view; }
Example #14
Source File: TransmitActivity.java From photon with MIT License | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_transmit); // Code for spinner Spinner mySpinner = (Spinner) findViewById(R.id.myspinner); ArrayAdapter<String> myAdapter = new ArrayAdapter<String>(TransmitActivity.this, android.R.layout.simple_list_item_1, getResources().getStringArray(R.array.menu_items)); myAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mySpinner.setAdapter(myAdapter); mySpinner.setOnItemSelectedListener(this); //Code for drop down ends, onSelect methods at buttom // TODO: Create an alert if flashlight is not present in device // TODO: Exit the app if no flashlight boolean hasFlash = this.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH); Log.d("Has Flashlight:", Boolean.toString(hasFlash)); if (!hasFlash) { showNoFlashLightAlert(); } }
Example #15
Source File: TableListFragment.java From android_dbinspector with Apache License 2.0 | 6 votes |
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); AppCompatActivity activity = (AppCompatActivity) getActivity(); List<String> tableList = DatabaseHelper.getAllTables(database); String version = DatabaseHelper.getVersion(database); ActionBar actionBar = activity.getSupportActionBar(); if (actionBar != null) { actionBar.setTitle(database.getName()); if (!TextUtils.isEmpty(version)) { actionBar.setSubtitle("v" + version); } actionBar.setDisplayHomeAsUpEnabled(true); } adapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_list_item_1, tableList); setListAdapter(adapter); getListView().setOnItemClickListener(tableClickListener); }
Example #16
Source File: PlayMovieActivity.java From pause-resume-video-recording with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_play_movie); mTextureView = (TextureView) findViewById(R.id.movie_texture_view); mTextureView.setSurfaceTextureListener(this); // Populate file-selection spinner. Spinner spinner = (Spinner) findViewById(R.id.playMovieFile_spinner); // Need to create one of these fancy ArrayAdapter thingies, and specify the generic layout // for the widget itself. mMovieFiles = MiscUtils.getFiles(Environment.getExternalStorageDirectory(), "*.mp4"); ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, mMovieFiles); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); // Apply the adapter to the spinner. spinner.setAdapter(adapter); spinner.setOnItemSelectedListener(this); updateControls(); }
Example #17
Source File: MainActivity.java From AndroidDemo with MIT License | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); textView = findViewById(R.id.textview); spinner = findViewById(R.id.spinner); textView.setText("您选择的城市是北京"); //1.设置数据源 list = new ArrayList<>(); list.add("北京"); list.add("上海"); list.add("广州"); list.add("深圳"); list.add("保定"); //2.定义适配器 adapter = new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item,list); //3.adapter设置下拉样式 adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); //4.spinner加载适配器 spinner.setAdapter(adapter); //5.spinner设置监听器 spinner.setOnItemSelectedListener(this); }
Example #18
Source File: SwitchVideoTypeDialog.java From GSYVideoPlayer with Apache License 2.0 | 6 votes |
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); }
Example #19
Source File: SensorResourceP.java From SI with BSD 2-Clause "Simplified" License | 6 votes |
public SensorResourceP(Activity main, Context c, ArrayList<String> list_item, ArrayAdapter<String> list_adapter) { super(main, c, list_item, list_adapter); resource_type = "gateway.sensorp"; resource_uri = "/gateway/sensorp"; mTemp = 0.0; mHumidity = 0.0; mLight = 0; mSound = 0; mTempListIndex = -1; mHumidityListIndex = -1; mLightListIndex = -1; mSoundListIndex = -1; msg_content_found = "msg_found_sensor_p"; msg_type_get_done = "msg_get_done_sensor_p"; update_thread_done = true; LocalBroadcastManager.getInstance(main_activity).registerReceiver(mSensorReadReceiver, new IntentFilter(msg_type_get_done)); }
Example #20
Source File: MainActivity.java From user-interface-samples with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mMainRelativeLayout = (RelativeLayout) findViewById(R.id.mainRelativeLayout); mNotificationDetailsTextView = (TextView) findViewById(R.id.notificationDetails); mSpinner = (Spinner) findViewById(R.id.spinner); mNotificationManagerCompat = NotificationManagerCompat.from(getApplicationContext()); // Create an ArrayAdapter using the string array and a default spinner layout. ArrayAdapter<CharSequence> adapter = new ArrayAdapter( this, android.R.layout.simple_spinner_item, NOTIFICATION_STYLES); // 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. mSpinner.setAdapter(adapter); mSpinner.setOnItemSelectedListener(this); }
Example #21
Source File: ScrollerEpActivity.java From PullRefreshView with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_scroller_ep); listView = (ListView) findViewById(R.id.list); headerView = (BaseHeaderView) findViewById(R.id.header); footerView = (BaseFooterView) findViewById(R.id.footer); list = getData(15); adapter = new ArrayAdapter(this, R.layout.item, list); listView.setAdapter(adapter); headerView.setOnRefreshListener(this); footerView.setOnLoadListener(this); }
Example #22
Source File: BlacklistActivity.java From ActivityForceNewTask with GNU General Public License v3.0 | 6 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); settingsHelper = new SettingsHelper(getApplicationContext()); listType = settingsHelper.getListType(); ArrayList<String> listItems = new ArrayList<String>(settingsHelper.getListItems(listType)); adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, listItems); setListAdapter(adapter); float scale = getResources().getDisplayMetrics().density; int padding = (int) (8 * scale + 0.5f); getListView().setPadding(padding * 2, padding, padding * 2, padding); getListView().setScrollBarStyle(View.SCROLLBARS_OUTSIDE_OVERLAY); getActionBar().setDisplayHomeAsUpEnabled(true); if (listType.equals(Common.PREF_BLACKLIST)) setTitle(R.string.list_type_entries_blacklist); else setTitle(R.string.list_type_entries_whitelist); }
Example #23
Source File: NavigationDrawerFragment.java From freeiot-android with MIT License | 6 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mDrawerListView = (ListView) inflater.inflate( R.layout.fragment_navigation_drawer, container, false); mDrawerListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { selectItem(position); } }); mDrawerListView.setAdapter(new ArrayAdapter<String>( getActionBar().getThemedContext(), R.layout.adapter_navigation_drawer, // android.R.layout.simple_list_item_1, android.R.id.text1, new String[]{ getString(R.string.my_devices), getString(R.string.logout), })); mDrawerListView.setItemChecked(mCurrentSelectedPosition, true); return mDrawerListView; }
Example #24
Source File: HeaderOverlayActivity.java From FadingActionBar with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); FadingActionBarHelper helper = new FadingActionBarHelper() .actionBarBackground(R.drawable.ab_background) .headerLayout(R.layout.header) .contentLayout(R.layout.activity_listview) .headerOverlayLayout(R.layout.header_overlay); setContentView(helper.createView(this)); helper.initActionBar(this); ListView listView = (ListView) findViewById(android.R.id.list); ArrayList<String> items = loadItems(R.raw.nyc_sites); ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, items); listView.setAdapter(adapter); }
Example #25
Source File: GalleryDetailScene.java From MHViewer with Apache License 2.0 | 6 votes |
private void bind(Pair<String, String>[] data) { if (null == mDialog || null == mProgressView || null == mErrorText || null == mListView) { return; } if (0 == data.length) { mProgressView.setVisibility(View.GONE); mErrorText.setVisibility(View.VISIBLE); mListView.setVisibility(View.GONE); mErrorText.setText(R.string.no_torrents); } else { String[] nameArray = new String[data.length]; for (int i = 0, n = data.length; i < n; i++) { nameArray[i] = data[i].second; } mProgressView.setVisibility(View.GONE); mErrorText.setVisibility(View.GONE); mListView.setVisibility(View.VISIBLE); mListView.setAdapter(new ArrayAdapter<>(mDialog.getContext(), R.layout.item_select_dialog, nameArray)); } }
Example #26
Source File: SimpleAlertDialog.java From SimpleAlertDialog-for-Android with Apache License 2.0 | 6 votes |
public void setItems(final CharSequence[] items, final AdapterView.OnItemClickListener listener) { mAdapter = new ArrayAdapter<CharSequence>(getContext(), android.R.layout.simple_list_item_1, items) { @Override public View getView(int position, View convertView, ViewGroup parent) { View view = super.getView(position, convertView, parent); if (view != null) { TextView tv = (TextView) view.findViewById(android.R.id.text1); if (mListItemTextStyle != 0) { tv.setTextAppearance(getContext(), mListItemTextStyle); } tv.setText(items[position]); } return view; } }; mListItemListener = listener; }
Example #27
Source File: MainActivity.java From AndroidDemoProjects with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); setSupportActionBar((Toolbar) findViewById(R.id.toolbar)); mListView = (ListView) findViewById(R.id.list); mAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, new ArrayList<String>()); mAdapter.add("Movie 1"); mAdapter.add("Movie 2"); mAdapter.add("Movie 3"); mAdapter.add("Movie 4"); mAdapter.add("Movie 5"); mAdapter.add("Movie 6"); mAdapter.add("Movie 7"); mListView.setAdapter(mAdapter); mListView.setOnItemClickListener(this); CastContext.getSharedInstance(this).addCastStateListener(this); CastContext.getSharedInstance(this).addAppVisibilityListener(this); CastContext.getSharedInstance(this).getSessionManager().addSessionManagerListener(this); }
Example #28
Source File: GoogleProgressBarActivity.java From UltimateAndroid with Apache License 2.0 | 5 votes |
private void refresh() { isRefreshing = true; getListView().setVisibility(View.GONE); mProgressBar.setVisibility(View.VISIBLE); getListView().postDelayed(new Runnable() { @Override public void run() { isRefreshing = false; getListView().setVisibility(View.VISIBLE); mProgressBar.setVisibility(View.GONE); setListAdapter(new ArrayAdapter<String>(getBaseContext(), R.layout.google_progress_bar_item_list, getListItem())); } }, REFRESH_TIME); }
Example #29
Source File: MainActivity.java From discreet-app-rate with Apache License 2.0 | 5 votes |
private void manageViews() { buttonBar = (LinearLayout) findViewById(R.id.button_bar); okButton = (Button) findViewById(R.id.ok_button); currentCount = (TextView) findViewById(R.id.curent_count); hasBeenClicked = (TextView) findViewById(R.id.has_been_clicked); isElpased = (TextView) findViewById(R.id.is_elapsed); lastCrash = (TextView) findViewById(R.id.last_crash); monitoredTime = (TextView) findViewById(R.id.monitored_time); initialCount = (EditText) findViewById(R.id.initial_count); text = (EditText) findViewById(R.id.text); delay = (EditText) findViewById(R.id.delay); retryPolicy = (Spinner) findViewById(R.id.retry_policy); theme = (Spinner) findViewById(R.id.theme); actionSpinner = (Spinner) findViewById(R.id.action_chooser); installTime = (EditText) findViewById(R.id.install_time); pauseAfterCrash = (EditText) findViewById(R.id.pause_after_crash); minimumMonitoringTime = (EditText) findViewById(R.id.minimum_monitoring_time); minimumInterval = (EditText) findViewById(R.id.minimum_interval); onTop = (CheckBox) findViewById(R.id.on_top); useCustomView = (CheckBox) findViewById(R.id.use_custom_view); ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.retry_policies, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); retryPolicy.setAdapter(adapter); ArrayAdapter<CharSequence> adapterTheme = ArrayAdapter.createFromResource(this, R.array.themes, android.R.layout.simple_spinner_item); adapterTheme.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); theme.setAdapter(adapterTheme); ArrayAdapter<CharSequence> actionAdapter = ArrayAdapter.createFromResource(this, R.array.actions, android.R.layout.simple_spinner_item); actionAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); actionSpinner.setAdapter(actionAdapter); }
Example #30
Source File: CuteSpinner.java From MHViewer with Apache License 2.0 | 5 votes |
private void init(Context context, AttributeSet attrs, int defStyleAttr) { TypedArray a = context.obtainStyledAttributes(attrs, androidx.appcompat.R.styleable.Spinner, defStyleAttr, 0); final CharSequence[] entries = a.getTextArray(R.styleable.Spinner_android_entries); if (entries != null) { final ArrayAdapter<CharSequence> adapter = new ArrayAdapter<>(context, R.layout.item_cute_spinner_item, entries); adapter.setDropDownViewResource(R.layout.support_simple_spinner_dropdown_item); setAdapter(adapter); } a.recycle(); }