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:edu.cmu.hcii.hangg.beeksbeacon.Fragments.ManageBeaconFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Log.i(TAG, "bi.id: " + beaconInstance.id + ", bi.googleType: " + beaconInstance.googleType); View rootView = inflater.inflate(R.layout.fragment_manage_beacon, container, false); advertisedId_Type = (TextView) rootView.findViewById(R.id.advertisedId_Type); advertisedId_Id = (TextView) rootView.findViewById(R.id.advertisedId_Id); status = (TextView) rootView.findViewById(R.id.status); placeId = (TextView) rootView.findViewById(R.id.placeId); placeId.setOnClickListener(new View.OnClickListener() { @Override//w w w . java2 s . c o m public void onClick(View v) { editLatLngAction(); } }); latLng = (TextView) rootView.findViewById(R.id.latLng); latLng.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { editLatLngAction(); } }); mapView = (ImageView) rootView.findViewById(R.id.mapView); mapView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { editLatLngAction(); } }); expectedStability = (TextView) rootView.findViewById(R.id.expectedStability); expectedStability.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()).setTitle("Edit Stability"); final ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(getActivity(), R.array.stability_enums, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); final Spinner spinner = new Spinner(getActivity()); spinner.setAdapter(adapter); // Set the position of the spinner to the current value. if (beaconInstance.expectedStability != null && !beaconInstance.expectedStability.equals(BeaconInstance.STABILITY_UNSPECIFIED)) { for (int i = 0; i < spinner.getCount(); i++) { if (beaconInstance.expectedStability.equals(spinner.getItemAtPosition(i))) { spinner.setSelection(i); } } } builder.setView(spinner); builder.setPositiveButton("Save", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { beaconInstance.expectedStability = (String) spinner.getSelectedItem(); updateBeacon(); dialog.dismiss(); } }); builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); builder.show(); } }); description = (TextView) rootView.findViewById(R.id.description); description.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()).setTitle("Edit description"); final EditText editText = new EditText(getActivity()); editText.setText(description.getText()); builder.setView(editText); builder.setPositiveButton("Save", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { beaconInstance.description = editText.getText().toString(); updateBeacon(); dialog.dismiss(); } }); builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); builder.show(); } }); actionButton = (Button) rootView.findViewById(R.id.actionButton); decommissionButton = (Button) rootView.findViewById(R.id.decommissionButton); decommissionButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { new AlertDialog.Builder(getActivity()).setTitle("Decommission Beacon") .setMessage("Are you sure you want to decommission this beacon? This operation is " + "irreversible and the beacon cannot be registered again") .setPositiveButton("Decommission", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); Callback decommissionCallback = new Callback() { @Override public void onFailure(Request request, IOException e) { logErrorAndToast("Failed request: " + request, e); } @Override public void onResponse(Response response) throws IOException { if (response.isSuccessful()) { beaconInstance.status = BeaconInstance.STATUS_DECOMMISSIONED; updateBeacon(); } else { String body = response.body().string(); logErrorAndToast("Unsuccessful decommissionBeacon request: " + body); } } }; client.decommissionBeacon(decommissionCallback, beaconInstance.getBeaconName()); } }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }).show(); } }); attachmentsDivider = rootView.findViewById(R.id.attachmentsDivider); attachmentsLabel = (TextView) rootView.findViewById(R.id.attachmentsLabel); attachmentsTable = (TableLayout) rootView.findViewById(R.id.attachmentsTableLayout); // Fetch the namespace for the developer console project ID. We redraw the UI once that // request completes. // TODO: cache this. Callback listNamespacesCallback = new Callback() { @Override public void onFailure(Request request, IOException e) { logErrorAndToast("Failed request: " + request, e); } @Override public void onResponse(Response response) throws IOException { String body = response.body().string(); if (response.isSuccessful()) { try { JSONObject json = new JSONObject(body); JSONArray namespaces = json.getJSONArray("namespaces"); // At present there can be only one namespace. String tmp = namespaces.getJSONObject(0).getString("namespaceName"); if (tmp.startsWith("namespaces/")) { namespace = tmp.substring("namespaces/".length()); } else { namespace = tmp; } redraw(); } catch (JSONException e) { Log.e(TAG, "JSONException", e); } } else { logErrorAndToast("Unsuccessful listNamespaces request: " + body); } } }; client.listNamespaces(listNamespacesCallback); return rootView; }
From source file:org.thaliproject.nativetest.app.fragments.SettingsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_settings, container, false); mSettings = Settings.getInstance(view.getContext()); mSettings.load();/* w w w . j av a 2 s. c o m*/ mConnectionTimeoutEditText = (EditText) view.findViewById(R.id.connectionTimeoutEditText); mConnectionTimeoutEditText.setText(String.valueOf(mSettings.getConnectionTimeout())); mConnectionTimeoutEditText.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void afterTextChanged(Editable editable) { if (editable.length() > 0) { try { mSettings.setConnectionTimeout(Long.parseLong(editable.toString())); } catch (NumberFormatException e) { Log.e(TAG, e.getMessage(), e); mConnectionTimeoutEditText.setText(String.valueOf(mSettings.getConnectionTimeout())); } } } }); mPortNumberEditText = (EditText) view.findViewById(R.id.portNumberEditText); mPortNumberEditText.setText(String.valueOf(mSettings.getPortNumber())); mPortNumberEditText.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void afterTextChanged(Editable editable) { if (editable.length() > 0 && !editable.toString().equals("-")) { try { mSettings.setPortNumber(Integer.parseInt(editable.toString())); } catch (NumberFormatException e) { Log.e(TAG, e.getMessage(), e); mPortNumberEditText.setText(String.valueOf(mSettings.getPortNumber())); } } } }); mListenForIncomingConnectionsCheckbox = (CheckBox) view .findViewById(R.id.listenForIncomingConnectionCheckbox); mListenForIncomingConnectionsCheckbox.setChecked(mSettings.getListenForIncomingConnections()); mListenForIncomingConnectionsCheckbox .setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { mSettings.setListenForIncomingConnections(b); } }); mHandshakeRequiredCheckbox = (CheckBox) view.findViewById(R.id.handshakeRequiredCheckBox); mHandshakeRequiredCheckbox.setChecked(mSettings.getHandshakeRequired()); mHandshakeRequiredCheckbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { mSettings.setHandshakeRequired(b); } }); mEnableWifiCheckBox = (CheckBox) view.findViewById(R.id.enableWifiCheckBox); mEnableWifiCheckBox.setChecked(mSettings.getEnableWifiDiscovery()); mEnableWifiCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { mSettings.setEnableWifiDiscovery(b); } }); mEnableBleCheckBox = (CheckBox) view.findViewById(R.id.enableBleCheckBox); mEnableBleCheckBox.setChecked(mSettings.getEnableBleDiscovery()); mEnableBleCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { mSettings.setEnableBleDiscovery(b); } }); Spinner spinner = (Spinner) view.findViewById(R.id.advertiseModeSpinner); ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(view.getContext(), R.array.advertise_mode_string_array, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter); spinner.setSelection(mSettings.getAdvertiseMode()); spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int index, long l) { mSettings.setAdvertiseMode(index); } @Override public void onNothingSelected(AdapterView<?> adapterView) { } }); spinner = (Spinner) view.findViewById(R.id.advertiseTxPowerLevelSpinner); adapter = ArrayAdapter.createFromResource(view.getContext(), R.array.advertise_tx_power_level_string_array, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter); spinner.setSelection(mSettings.getAdvertiseTxPowerLevel()); spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int index, long l) { mSettings.setAdvertiseTxPowerLevel(index); } @Override public void onNothingSelected(AdapterView<?> adapterView) { } }); spinner = (Spinner) view.findViewById(R.id.scanModeSpinner); adapter = ArrayAdapter.createFromResource(view.getContext(), R.array.scan_mode_string_array, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter); spinner.setSelection(mSettings.getScanMode()); spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int index, long l) { mSettings.setScanMode(index); } @Override public void onNothingSelected(AdapterView<?> adapterView) { } }); mBufferSizeEditText = (EditText) view.findViewById(R.id.bufferSizeEditText); mBufferSizeEditText.setText(String.valueOf(mSettings.getBufferSize())); mBufferSizeEditText.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void afterTextChanged(Editable editable) { if (editable.length() > 0) { try { mSettings.setBufferSize(Integer.parseInt(editable.toString())); } catch (NumberFormatException e) { Log.e(TAG, e.getMessage(), e); mBufferSizeEditText.setText(String.valueOf(mSettings.getBufferSize())); } } } }); mDataAmountEditText = (EditText) view.findViewById(R.id.dataAmountEditText); mDataAmountEditText.setText(String.valueOf(mSettings.getDataAmount())); mDataAmountEditText.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void afterTextChanged(Editable editable) { if (editable.length() > 0) { try { mSettings.setDataAmount(Long.parseLong(editable.toString())); } catch (NumberFormatException e) { Log.e(TAG, e.getMessage(), e); mDataAmountEditText.setText(String.valueOf(mSettings.getDataAmount())); } } } }); mEnableAutoConnectCheckBox = (CheckBox) view.findViewById(R.id.autoConnectCheckBox); mEnableAutoConnectCheckBox.setChecked(mSettings.getAutoConnect()); mEnableAutoConnectCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { mSettings.setAutoConnect(b); } }); mEnableAutoConnectEvenWhenIncomingConnectionEstablishedCheckBox = (CheckBox) view .findViewById(R.id.autoConnectEvenWhenIncomingCheckBox); mEnableAutoConnectEvenWhenIncomingConnectionEstablishedCheckBox .setChecked(mSettings.getAutoConnectEvenWhenIncomingConnectionEstablished()); mEnableAutoConnectEvenWhenIncomingConnectionEstablishedCheckBox .setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { mSettings.setAutoConnectEvenWhenIncomingConnectionEstablished(b); } }); return view; }
From source file:com.micabyte.android.app.BaseFragment.java
@SuppressWarnings("ConstantConditions") protected Spinner setSpinner(int resId, int arrId) { final Spinner s = (Spinner) getView().findViewById(resId); final ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource( getActivity().getApplicationContext(), arrId, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); s.setAdapter(adapter);/*from w w w. jav a 2 s . c om*/ return s; }
From source file:org.dmfs.webcal.fragments.CalendarSettingsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View root = inflater.inflate(R.layout.fragment_calendar_settings, container, false); root.findViewById(R.id.color_setting).setOnClickListener(this); root.findViewById(R.id.name_setting).setOnClickListener(this); root.findViewById(R.id.alarm_setting).setOnClickListener(this); mColorPreview = (ImageView) root.findViewById(R.id.color_preview); mCalendarName = (TextView) root.findViewById(R.id.calendar_name); mAlarmSpinner = (Spinner) root.findViewById(R.id.calendar_reminder); mColorPreview.setBackgroundColor(mNewColor); mCalendarName.setText(mNewName);/*from w w w .j ava 2s .com*/ if (mAlarmSpinner != null) { ArrayAdapter<CharSequence> mAlarmAdapter = ArrayAdapter.createFromResource(inflater.getContext(), R.array.alarm_names, R.layout.simple_spinner_item); mAlarmAdapter.setDropDownViewResource(R.layout.simple_spinner_dropdown_item); mAlarmSpinner.setAdapter(mAlarmAdapter); } LoaderManager loaderManage = getLoaderManager(); loaderManage.initLoader(ID_SUBSCRIPTION_LOADER, null, this); return root; }
From source file:com.chriscartland.octaviastreethilton.ui.MainActivity.java
private void createDrawer() { // Now retrieve the DrawerLayout so that we can set the status bar color. // This only takes effect on Lollipop, or when using translucentStatusBar // on KitKat. DrawerLayout drawerLayout = (DrawerLayout) findViewById(R.id.drawer_main); drawerLayout.setStatusBarBackgroundColor(getResources().getColor(R.color.color_primary_dark)); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_main); ArrayAdapter drawerAdapter = ArrayAdapter.createFromResource(this, R.array.navigation_array, R.layout.drawer_list_item);/*w w w .j a v a 2 s. c o m*/ mDrawerNavigation = (ListView) findViewById(R.id.drawer_navigation); mDrawerNavigation.setAdapter(drawerAdapter); mDrawerNavigation.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { setTitle(parent.getItemAtPosition(position).toString()); mDrawerLayout.closeDrawer(Gravity.START); } }); setTitle(mDrawerNavigation.getItemAtPosition(0).toString()); }
From source file:com.example.android.drawabletinting.DrawableTintingFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.tinting_fragment, null); // Set a drawable as the image to display mImage = (ImageView) v.findViewById(R.id.image); mImage.setImageResource(R.drawable.btn_default_normal_holo); // Get text labels and seekbars for the four color components: ARGB mAlphaBar = (SeekBar) v.findViewById(R.id.alphaSeek); mAlphaText = (TextView) v.findViewById(R.id.alphaText); mGreenBar = (SeekBar) v.findViewById(R.id.greenSeek); mGreenText = (TextView) v.findViewById(R.id.greenText); mRedBar = (SeekBar) v.findViewById(R.id.redSeek); mRedText = (TextView) v.findViewById(R.id.redText); mBlueText = (TextView) v.findViewById(R.id.blueText); mBlueBar = (SeekBar) v.findViewById(R.id.blueSeek); // Set a listener to update tinted image when selections have changed mAlphaBar.setOnSeekBarChangeListener(mSeekBarListener); mRedBar.setOnSeekBarChangeListener(mSeekBarListener); mGreenBar.setOnSeekBarChangeListener(mSeekBarListener); mBlueBar.setOnSeekBarChangeListener(mSeekBarListener); // Set up the spinner for blend mode selection from a string array resource mBlendSpinner = (Spinner) v.findViewById(R.id.blendSpinner); SpinnerAdapter sa = ArrayAdapter.createFromResource(getActivity(), R.array.blend_modes, android.R.layout.simple_spinner_dropdown_item); mBlendSpinner.setAdapter(sa);//www. j a v a 2 s . c o m // Set a listener to update the tinted image when a blend mode is selected mBlendSpinner.setOnItemSelectedListener(mBlendListener); // Select the first item mBlendSpinner.setSelection(0); mMode = MODES[0]; if (savedInstanceState != null) { // Restore the previous state if this fragment has been restored mBlendSpinner.setSelection(savedInstanceState.getInt(STATE_BLEND)); mAlphaBar.setProgress(savedInstanceState.getInt(STATE_ALPHA)); mRedBar.setProgress(savedInstanceState.getInt(STATE_RED)); mGreenBar.setProgress(savedInstanceState.getInt(STATE_GREEN)); mBlueBar.setProgress(savedInstanceState.getInt(STATE_BLUE)); } // Apply the default blend mode and color updateTint(getColor(), getTintMode()); return v; }
From source file:de.gadc.moneybeam.MoneyBeamActivity.java
/** * This method handles the initialization of the whole UI. *///from w w w .j av a 2 s .co m private void initUi() { dollars = (EditText) findViewById(R.id.money_dollars); cents = (EditText) findViewById(R.id.money_cents); currency = (Spinner) findViewById(R.id.money_currency); adapter = ArrayAdapter.createFromResource(this, R.array.currencies, R.layout.spinner_text); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); currency.setAdapter(adapter); }
From source file:uk.ac.horizon.artcodes.fragment.ActionEditDialogFragment.java
@NonNull @Override//from w ww. jav a 2 s . c om public Dialog onCreateDialog(Bundle savedInstanceState) throws NullPointerException { binding = ActionEditBinding.inflate(getActivity().getLayoutInflater()); binding.newMarkerCode.setFilters(new InputFilter[] { new MarkerFormat() }); String currentKeyboard = Settings.Secure.getString(getContext().getContentResolver(), Settings.Secure.DEFAULT_INPUT_METHOD); Log.i("Keyboard", currentKeyboard); if (currentKeyboard.contains("com.lge.ime")) { binding.newMarkerCode.setKeyListener(DigitsKeyListener.getInstance("0123456789:")); binding.newMarkerCode.setRawInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL); } binding.newMarkerCode.addTextChangedListener(new SimpleTextWatcher() { @Override public String getText() { return null; } @Override public void onTextChanged(String value) { if (!value.isEmpty()) { binding.newMarkerCode.setText(""); Action action = getAction(); action.getCodes().add(value); ActionCodeBinding codeBinding = createCodeBinding(binding, action, action.getCodes().size() - 1); codeBinding.editMarkerCode.requestFocus(); } } }); binding.scanButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(getActivity(), ScannerActivity.class); intent.putExtra("experience", "{\"name\":\"Scan Code\"}"); startActivityForResult(intent, SCAN_CODE_REQUEST); } }); final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setView(binding.getRoot()); final Dialog dialog = builder.create(); binding.deleteButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (getArguments().containsKey("action")) { dialog.dismiss(); final int index = getArguments().getInt("action"); if (getTargetFragment() instanceof ActionEditListFragment) { ((ActionEditListFragment) getTargetFragment()).getAdapter().deleteAction(index); } else { getExperience().getActions().remove(index); } } } }); binding.doneButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (getArguments().containsKey("action")) { updateAction(); // make sure code is sorted if (getAction().getCodes().size() == 1) { // Actions with only 1 code can not be a group or sequence! getAction().setMatch(Action.Match.any); } final int index = getArguments().getInt("action"); if (getTargetFragment() instanceof ActionEditListFragment) { ((ActionEditListFragment) getTargetFragment()).getAdapter().actionUpdated(index); } } dialog.dismiss(); } }); ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this.getContext(), R.array.match_type_descriptions, R.layout.match_type_spinner_item); binding.matchSpinner.setAdapter(adapter); binding.matchSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { if (getAction() != null) { switch (i) { case 0: getAction().setMatch(Action.Match.any); break; case 1: getAction().setMatch(Action.Match.all); break; case 2: getAction().setMatch(Action.Match.sequence); break; } } } @Override public void onNothingSelected(AdapterView<?> adapterView) { } }); if (Feature.get(getContext(), R.bool.feature_combined_markers).isEnabled()) { binding.selectLayout.setVisibility(View.GONE); binding.matchSpinner.setVisibility(View.VISIBLE); } // Upload to artcodes.co.uk feature button: if (Feature.get(getContext(), R.bool.feature_upload_to_artcodes_co_uk).isEnabled()) { binding.uploadToArtcodesCoUkButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { UUID uuid = UUID.randomUUID(); String url = "http://www.artcodes.co.uk/test1234/?file=A" + uuid.toString() + "&source=artcodes-android-app"; getAction().setUrl(url); updateAction(); Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); intent.setData(Uri.parse(url + "&dontCheckForFiles")); startActivity(intent); } }); binding.uploadToArtcodesCoUkButton.setVisibility(View.VISIBLE); } return dialog; }
From source file:com.example.android.cupboard.EditorActivity.java
/** * Setup the dropdown spinner that allows the user to select the units for the amount of food. *///from w ww .java 2s . com private void setupSpinner() { // Create adapter for spinner. The list options are from the String array it will use // the spinner will use the default layout ArrayAdapter unitsSpinnerAdapter = ArrayAdapter.createFromResource(this, R.array.array_units_options, android.R.layout.simple_spinner_item); // Specify dropdown layout style - simple list view with 1 item per line unitsSpinnerAdapter.setDropDownViewResource(android.R.layout.simple_dropdown_item_1line); // Apply the adapter to the spinner mUnitsSpinner.setAdapter(unitsSpinnerAdapter); // Set the integer mSelected to the constant values mUnitsSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { String selection = (String) parent.getItemAtPosition(position); if (!TextUtils.isEmpty(selection)) { if (selection.equals(getString(R.string.units_g))) { mUnit = FoodEntry.UNITS_G; } else if (selection.equals(getString(R.string.units_kg))) { mUnit = FoodEntry.UNITS_KG; } else if (selection.equals(getString(R.string.units_ml))) { mUnit = FoodEntry.UNITS_ML; } else if (selection.equals(getString(R.string.units_l))) { mUnit = FoodEntry.UNITS_L; } else { mUnit = FoodEntry.UNITS_UNKNOWN; } } } // Because AdapterView is an abstract class, onNothingSelected must be defined @Override public void onNothingSelected(AdapterView<?> parent) { mUnit = FoodEntry.UNITS_UNKNOWN; } }); }
From source file:com.owo.android.mtPlease.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Set up the action bar final ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); actionBar.setDisplayShowTitleEnabled(false); actionBar.setHomeButtonEnabled(true); actionBar.setDisplayHomeAsUpEnabled(true); // setting for the sidedrawer // set the content view setBehindContentView(R.layout.drawer_search); getSlidingMenu().setFadeEnabled(true); getSlidingMenu().setShadowWidthRes(R.dimen.shadow_width); getSlidingMenu().setShadowDrawable(R.drawable.shadow); getSlidingMenu().setFadeDegree(0.90f); searchDrawerCloseButton = (ImageButton) findViewById(R.id.button_search_drawer_close); searchDrawerCloseButton.setOnClickListener(new OnClickListener() { @Override/*from w ww. j a v a 2s . c om*/ public void onClick(View v) { // TODO Auto-generated method stub getSlidingMenu().showContent(); } }); // Create the adapter that will return a fragment for each of the three // primary sections of the activity. mSectionsPagerAdapter = new SectionsPagerAdapter(getFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mSectionsPagerAdapter); // When swiping between different sections, select the corresponding // tab. We can also use ActionBar.Tab#select() to do this if we have // a reference to the Tab. mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { actionBar.setSelectedNavigationItem(position); } }); // mViewPager.setOffscreenPageLimit(3); // For each of the sections in the app, add a tab to the action bar. for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) { // Create a tab with text corresponding to the page title defined by // the adapter. Also specify this Activity object, which implements // the TabListener interface, as the callback (listener) for when // this tab is selected. actionBar .addTab(actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this)); } locationSelectSpinner = (Spinner) findViewById(R.id.spinner_location); ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.location_array, R.layout.spinner_text); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); locationSelectSpinner.setAdapter(adapter); datePickerButton = (Button) findViewById(R.id.button_datepicker); datePickerButton.setText(modifiedDate); datePickerButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub FragmentManager dialogManager = getFragmentManager(); CalendarDialogFragment calendarDialogFragment = new CalendarDialogFragment(); calendarDialogFragment.setParentCaller(CalendarDialogFragment.PARENT_IS_ACTIVITY); calendarDialogFragment.show(dialogManager, "calendar_dialog_popped"); } }); // Activity emailAddress(SESSION_ID) MyPageFragment // . // searchButton = (ImageButton) findViewById(R.id.imageButton_search); searchButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub try { String region = locationSelectSpinner.getSelectedItem().toString(); if (region.equals("")) { region = "1"; } else if (region.equals("")) { region = "2"; } else { region = "3"; } String people = ((EditText) findViewById(R.id.editText_numberPeople)).getText().toString(); String[] tmp = (datePickerButton.getText().toString()).split(" "); String date = tmp[0].substring(0, 4) + "-" + tmp[1].split("")[0] + "-" + tmp[2].split("")[0]; String query = "?region=" + region + "&people=" + people + "&date=" + date + "&flag=1"; sendInfoToFragment(people, 2); sendInfoToFragment(query, 0); getSlidingMenu().showContent(); } catch (Exception e) { // TODO Auto-generated catch block Toast.makeText(getApplicationContext(), " ", Toast.LENGTH_SHORT); e.printStackTrace(); } } }); }