List of usage examples for android.widget ArrayAdapter createFromResource
public static @NonNull ArrayAdapter<CharSequence> createFromResource(@NonNull Context context, @ArrayRes int textArrayResId, @LayoutRes int textViewResId)
From source file:com.hardcopy.retrowatch.WatchControlFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_watch_control, container, false); mEditGmailAddr = (EditText) rootView.findViewById(R.id.edit_email_addr); String defaultAddr = Settings.getInstance(mContext).getGmailAddress(); if (defaultAddr != null && !defaultAddr.isEmpty()) mEditGmailAddr.setText(defaultAddr); mEditGmailAddr.addTextChangedListener(new TextWatcher() { @Override/*ww w .j a v a 2 s . co m*/ public void onTextChanged(CharSequence s, int start, int before, int count) { String addr = s.toString(); if (addr != null && !addr.isEmpty()) { mFragmentListener.OnFragmentCallback(IFragmentListener.CALLBACK_REQUEST_SET_EMAIL_ADDRESS, 0, 0, addr, null, null); } } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable s) { } }); mSpinnerClockStyle = (Spinner) rootView.findViewById(R.id.spinner_clock_style); ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(mContext, R.array.clock_style_array, R.layout.spinner_simple_item2); adapter.setDropDownViewResource(R.layout.spinner_dropdown_simple_item); mSpinnerClockStyle.setPrompt(mContext.getString(R.string.clock_style_title)); mSpinnerClockStyle.setAdapter(adapter); mSpinnerClockStyle.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { if (mPresetClockStyle > -1 && mPresetClockStyle != position) { mFragmentListener.OnFragmentCallback(IFragmentListener.CALLBACK_REQUEST_CLOCK_STYLE, position, 0, null, null, null); } mPresetClockStyle = position; } @Override public void onNothingSelected(AdapterView<?> arg0) { } }); // Clock indicator style selector mSpinnerIndicator = (Spinner) rootView.findViewById(R.id.spinner_show_indicator); ArrayAdapter<CharSequence> adapter2 = ArrayAdapter.createFromResource(mContext, R.array.clock_indicator_array, R.layout.spinner_simple_item2); adapter.setDropDownViewResource(R.layout.spinner_dropdown_simple_item); mSpinnerIndicator.setPrompt(mContext.getString(R.string.clock_indicator_title)); mSpinnerIndicator.setAdapter(adapter2); mSpinnerIndicator.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { if (mPresetIndicator > -1 && mPresetIndicator != position) { mFragmentListener.OnFragmentCallback(IFragmentListener.CALLBACK_REQUEST_SHOW_INDICATOR, position, 0, null, null, null); } mPresetIndicator = position; } @Override public void onNothingSelected(AdapterView<?> arg0) { } }); // 'Run in background' setting mCheckBackground = (CheckBox) rootView.findViewById(R.id.check_background_service); mCheckBackground.setChecked(Settings.getInstance(mContext).getRunInBackground()); mCheckBackground.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { Settings.getInstance(mContext).setRunInBackground(isChecked); mFragmentListener.OnFragmentCallback(IFragmentListener.CALLBACK_REQUEST_RUN_IN_BACKGROUND, 0, 0, null, null, null); } }); return rootView; }
From source file:com.hardcopy.retrowatchle.WatchControlFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_watch_control, container, false); mEditGmailAddr = (EditText) rootView.findViewById(R.id.edit_email_addr); String defaultAddr = Settings.getInstance(mContext).getGmailAddress(); if (defaultAddr != null && !defaultAddr.isEmpty()) mEditGmailAddr.setText(defaultAddr); mEditGmailAddr.addTextChangedListener(new TextWatcher() { @Override/* w ww . j ava 2 s . c om*/ public void onTextChanged(CharSequence s, int start, int before, int count) { String addr = s.toString(); if (addr != null && !addr.isEmpty()) { mFragmentListener.OnFragmentCallback(IFragmentListener.CALLBACK_REQUEST_SET_EMAIL_ADDRESS, 0, 0, addr, null, null); } } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable s) { } }); mSpinnerClockStyle = (Spinner) rootView.findViewById(R.id.spinner_clock_style); ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(mContext, R.array.clock_style_array, R.layout.spinner_simple_item2); adapter.setDropDownViewResource(R.layout.spinner_dropdown_simple_item); mSpinnerClockStyle.setPrompt(mContext.getString(R.string.clock_style_title)); mSpinnerClockStyle.setAdapter(adapter); mSpinnerClockStyle.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { if (mPresetClockStyle > -1 && mPresetClockStyle != position) { mFragmentListener.OnFragmentCallback(IFragmentListener.CALLBACK_REQUEST_CLOCK_STYLE, position, 0, null, null, null); } mPresetClockStyle = position; } @Override public void onNothingSelected(AdapterView<?> arg0) { } }); mSpinnerIndicator = (Spinner) rootView.findViewById(R.id.spinner_show_indicator); ArrayAdapter<CharSequence> adapter2 = ArrayAdapter.createFromResource(mContext, R.array.clock_indicator_array, R.layout.spinner_simple_item2); adapter.setDropDownViewResource(R.layout.spinner_dropdown_simple_item); mSpinnerIndicator.setPrompt(mContext.getString(R.string.clock_indicator_title)); mSpinnerIndicator.setAdapter(adapter2); mSpinnerIndicator.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { if (mPresetIndicator > -1 && mPresetIndicator != position) { mFragmentListener.OnFragmentCallback(IFragmentListener.CALLBACK_REQUEST_SHOW_INDICATOR, position, 0, null, null, null); } mPresetIndicator = position; } @Override public void onNothingSelected(AdapterView<?> arg0) { } }); // 'Run in background' setting mCheckBackground = (CheckBox) rootView.findViewById(R.id.check_background_service); mCheckBackground.setChecked(Settings.getInstance(mContext).getRunInBackground()); mCheckBackground.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { Settings.getInstance(mContext).setRunInBackground(isChecked); mFragmentListener.OnFragmentCallback(IFragmentListener.CALLBACK_REQUEST_RUN_IN_BACKGROUND, 0, 0, null, null, null); } }); return rootView; }
From source file:fr.mixit.android.ui.SessionsActivity.java
@Override protected void onCreate(Bundle savedStateInstance) { super.onCreate(savedStateInstance); mMode = getIntent().getIntExtra(EXTRA_MODE, DISPLAY_MODE_SESSIONS); if (mMode != DISPLAY_MODE_SESSIONS_STARRED && mMode != DISPLAY_MODE_SESSIONS_DUPLICATE) { final Context context = getSupportActionBar().getThemedContext(); final ArrayAdapter<CharSequence> listAdapter = ArrayAdapter.createFromResource(context, R.array.sessions, R.layout.sherlock_spinner_item); listAdapter.setDropDownViewResource(R.layout.sherlock_spinner_dropdown_item); getSupportActionBar().setListNavigationCallbacks(listAdapter, this); getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); }//ww w.j a v a 2 s. c om if (savedStateInstance != null) { mMode = savedStateInstance.getInt(STATE_DISPLAY_MODE, mMode); } final FragmentManager fm = getSupportFragmentManager(); mSessionsListFrag = (SessionsListFragment) fm.findFragmentByTag(SessionsListFragment.TAG); if (mSessionsListFrag == null) { mSessionsListFrag = SessionsListFragment.newInstance(getIntent()); fm.beginTransaction().add(R.id.content_sessions_list, mSessionsListFrag, SessionsListFragment.TAG) .commit(); } if (mMode != DISPLAY_MODE_SESSIONS_STARRED && mMode != DISPLAY_MODE_SESSIONS_DUPLICATE) { int itemSelected = 0; switch (mMode) { case DISPLAY_MODE_SESSIONS: itemSelected = 0; break; case DISPLAY_MODE_LIGHTNING_TALKS: itemSelected = 1; break; default: itemSelected = 0; break; } getSupportActionBar().setSelectedNavigationItem(itemSelected); getSupportActionBar().setDisplayShowTitleEnabled(false); } else if (mMode == DISPLAY_MODE_SESSIONS_DUPLICATE) { final ActionBar sab = getSupportActionBar(); final long slotStart = getIntent().getLongExtra(SessionsActivity.EXTRA_SLOT_START, -1); final long slotEnd = getIntent().getLongExtra(SessionsActivity.EXTRA_SLOT_END, -1); final String title = DateUtils.formatDayTime(this, slotStart, slotEnd); sab.setTitle(title); getSupportActionBar().setDisplayShowTitleEnabled(true); } else { getSupportActionBar().setDisplayShowTitleEnabled(false); } mSessionsListFrag.setDisplayMode(mMode); if (UIUtils.isTablet(this)) { mSessionDetailsFrag = (SessionDetailsFragment) fm.findFragmentByTag(SessionDetailsFragment.TAG); if (mSessionDetailsFrag == null) { mSessionDetailsFrag = SessionDetailsFragment.newInstance(getIntent()); fm.beginTransaction() .add(R.id.content_session_details, mSessionDetailsFrag, SessionDetailsFragment.TAG) .commit(); } } }
From source file:com.javielinux.fragments.SearchAdvancedFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = View.inflate(getActivity(), R.layout.search_advanced_fragment, null); btInfoNotifications = (Button) view.findViewById(R.id.bt_info_notifications); btInfoNotifications.setOnClickListener(new View.OnClickListener() { @Override/* w w w . j ava 2s . com*/ public void onClick(View v) { String file = "notifications_use.txt"; if (Locale.getDefault().getLanguage().equals("es")) { file = "notifications_use_es.txt"; } try { AlertDialog builder = DialogUtils.PersonalDialogBuilder.create(getActivity(), getActivity().getString(R.string.notifications), file); builder.show(); } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } } }); languages = (Spinner) view.findViewById(R.id.sp_languages); attitude = (Spinner) view.findViewById(R.id.sp_attitude); filter = (Spinner) view.findViewById(R.id.sp_filter); noRetweet = (CheckBox) view.findViewById(R.id.cb_no_retweet); source = (EditText) view.findViewById(R.id.et_source); ArrayAdapter<?> adapterLanguages = ArrayAdapter.createFromResource(getActivity(), R.array.languages, android.R.layout.simple_spinner_item); adapterLanguages.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); languages.setAdapter(adapterLanguages); ArrayAdapter<?> adapterAttitude = ArrayAdapter.createFromResource(getActivity(), R.array.attitude, android.R.layout.simple_spinner_item); adapterAttitude.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); attitude.setAdapter(adapterAttitude); ArrayAdapter<?> adapterFilter = ArrayAdapter.createFromResource(getActivity(), R.array.filter, android.R.layout.simple_spinner_item); adapterFilter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); filter.setAdapter(adapterFilter); notifications = (CheckBox) view.findViewById(R.id.cb_notifications); notificationsBar = (CheckBox) view.findViewById(R.id.cb_notifications_bar); notifications.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { if (searchIsNotification) { showFields(); } else { int max = Utils.MAX_NOTIFICATIONS; if (Utils.isLite(getActivity())) { max = Utils.MAX_NOTIFICATIONS_LITE; } int size = DataFramework.getInstance().getEntityList("search", "notifications=1").size() + 1; if (size <= max) { showFields(); } else { notifications.setChecked(false); if (Utils.isLite(getActivity())) { Utils.showMessage(getActivity(), getActivity().getString(R.string.max_notifications_lite)); } else { Utils.showMessage(getActivity(), getActivity().getString(R.string.max_notifications)); } } } } else { hideFields(); } } }); populateFields(); return view; }
From source file:com.nks.nksmod.otaupdater.DownloadsActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); String extState = Environment.getExternalStorageState(); if (!extState.equals(Environment.MEDIA_MOUNTED) && !extState.equals(Environment.MEDIA_MOUNTED_READ_ONLY)) { Toast.makeText(this, extState.equals(Environment.MEDIA_SHARED) ? R.string.toast_nosd_shared : R.string.toast_nosd_error, Toast.LENGTH_LONG).show(); finish();/*from www. j av a 2 s. com*/ } setContentView(R.layout.downloads); dlFragment = (DownloadListFragment) getFragmentManager().findFragmentById(R.id.download_list); bar = getActionBar(); assert bar != null; bar.setDisplayHomeAsUpEnabled(true); bar.setDisplayShowTitleEnabled(false); bar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); bar.setListNavigationCallbacks(ArrayAdapter.createFromResource(this, R.array.download_types, android.R.layout.simple_spinner_dropdown_item), this); int state = -1; String action = getIntent().getAction(); if (action != null) { if (action.equals(FLASH_ROM_ACTION)) { state = GOTO_TYPE_ROM; showFlashDialog(RomInfo.FACTORY.fromIntent(getIntent())); /* } else if (action.equals(FLASH_KERNEL_ACTION)) { state = GOTO_TYPE_KERNEL; showFlashDialog(KernelInfo.FACTORY.fromIntent(getIntent())); */ } else { state = getIntent().getIntExtra(EXTRA_GOTO_TYPE, state); } } if (savedInstanceState != null) { if (state == -1) state = savedInstanceState.getInt("state", dlFragment.getState()); } bar.setSelectedNavigationItem(state); }
From source file:pt.carlos.alex.rosario.MainActivity.java
/** * Inicializao depois da criao das views. Determina se o layout inclui 2 * views. Notifica o novo estado da aplicao. *///from w ww . j av a 2 s . c o m @AfterViews void afterCreate() { mEventBus.register(this); ab = getSupportActionBar(); ab.setDisplayShowTitleEnabled(false); ab.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); ArrayAdapter<CharSequence> weekDaysList; weekDaysList = ArrayAdapter.createFromResource(ab.getThemedContext(), R.array.week_days, R.layout.sherlock_spinner_item); weekDaysList.setDropDownViewResource(R.layout.sherlock_spinner_dropdown_item); ab.setListNavigationCallbacks(weekDaysList, this); this.escreveTitulo(); if (mSlindingMenu != null) { ab.setDisplayHomeAsUpEnabled(true); } mEventBus.post(new Estado(mIndexDiaSemana, mMisterioSelected, mPaginaActual)); if (V.DEBUG) { Log.d(TAG, "Triggered event Estado. Dia:" + mIndexDiaSemana + "; Mistrio:" + mMisterioSelected + "; Pgina:" + mPaginaActual); } }
From source file:com.chaitu.lmscalendar.ui.UrlDialog.java
@Override @NonNull//from w w w. jav a 2s . c om 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.example.deii.trustone.SignUpActivity.java
private void InitViews() { toolbar = (Toolbar) findViewById(R.id.toolbar); //toolbar.setTitle("Sign Up"); setSupportActionBar(toolbar);/*w w w. jav a 2 s .com*/ progressDialog = new CustomProgressDialog(this, R.drawable.syc); spinState = (Spinner) findViewById(R.id.spinState); ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.state_array, R.layout.text_view); adapter.setDropDownViewResource(R.layout.text_view); spinState.setAdapter(adapter); spinState.setOnItemSelectedListener(this); imgProfile = (RoundedImageView) findViewById(R.id.imgProfile); imgProfile.setOnClickListener(this); txtConnect = (TextView) findViewById(R.id.txtConnect); txtConnect.setOnClickListener(this); tilName = (TextInputLayout) findViewById(R.id.tilName); edtName = (EditText) findViewById(R.id.edtName); edtName.addTextChangedListener(new MyTextWatcher(edtName)); tilEmail = (TextInputLayout) findViewById(R.id.tilEmail); edtEmail = (EditText) findViewById(R.id.edtEmail); edtEmail.addTextChangedListener(new MyTextWatcher(edtEmail)); tilPhone = (TextInputLayout) findViewById(R.id.tilPhone); edtPhone = (EditText) findViewById(R.id.edtPhone); edtPhone.addTextChangedListener(new MyTextWatcher(edtPhone)); tilCity = (TextInputLayout) findViewById(R.id.tilCity); edtCity = (EditText) findViewById(R.id.edtCity); edtCity.addTextChangedListener(new MyTextWatcher(edtCity)); tilLicense = (TextInputLayout) findViewById(R.id.tilLicense); edtLicense = (EditText) findViewById(R.id.edtLicense); tilPassword = (TextInputLayout) findViewById(R.id.tilPassword); edtPassword = (EditText) findViewById(R.id.edtPassword); edtPassword.addTextChangedListener(new MyTextWatcher(edtPassword)); tilConfPassword = (TextInputLayout) findViewById(R.id.tilConfPassword); edtConfPassword = (EditText) findViewById(R.id.edtPassword); edtConfPassword.addTextChangedListener(new MyTextWatcher(edtConfPassword)); functions = new CommonFunctions(this); }
From source file:com.google.maps.android.utils.demo.HeatmapsDemoActivity.java
@Override protected void startDemo() { getMap().moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(-25, 143), 4)); // Set up the spinner/dropdown list Spinner spinner = (Spinner) findViewById(R.id.spinner); ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.heatmaps_datasets_array, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter);/*www . j av a 2 s . c om*/ spinner.setOnItemSelectedListener(new SpinnerActivity()); try { mLists.put(getString(R.string.police_stations), new DataSet(readItems(R.raw.police), getString(R.string.police_stations_url))); mLists.put(getString(R.string.medicare), new DataSet(readItems(R.raw.medicare), getString(R.string.medicare_url))); } catch (JSONException e) { Toast.makeText(this, "Problem reading list of markers.", Toast.LENGTH_LONG).show(); } // Make the handler deal with the map // Input: list of WeightedLatLngs, minimum and maximum zoom levels to calculate custom // intensity from, and the map to draw the heatmap on // radius, gradient and opacity not specified, so default are used }
From source file:com.battlelancer.seriesguide.ui.FirstRunFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); // add button getView().findViewById(R.id.buttonFirstRunAddShow).setOnClickListener(new OnClickListener() { @Override//from w w w . j a v a2 s. c o m public void onClick(View v) { fireTrackerEvent("Add show"); startActivity(new Intent(getActivity(), AddActivity.class)); setFirstRunDismissed(); } }); // language chooser Spinner spinner = (Spinner) getView().findViewById(R.id.welcome_setuplanguage); ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(getActivity(), R.array.languages, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter); spinner.setOnItemSelectedListener(new OnLanguageSelectedListener()); // trakt connect button getView().findViewById(R.id.welcome_setuptrakt).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { fireTrackerEvent("Connect trakt"); Intent i = new Intent(getActivity(), ConnectTraktActivity.class); startActivity(i); } }); // dismiss button View buttonDismiss = getView().findViewById(R.id.buttonFirstRunDismiss); CheatSheet.setup(buttonDismiss); buttonDismiss.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { fireTrackerEvent("Dismiss"); setFirstRunDismissed(); } }); setHasOptionsMenu(true); }