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.creationgroundmedia.taskmaster.TaskDetailFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mView = inflater.inflate(R.layout.task_detail, container, false); mNameView = (EditText) mView.findViewById(R.id.task_detail_name); mDescriptionView = (EditText) mView.findViewById(R.id.task_detail_description); mDateView = (DatePicker) mView.findViewById(R.id.task_detail_due_date); mCompletedView = (CheckBox) mView.findViewById(R.id.task_detail_status); ArrayAdapter<CharSequence> spinnerAdapter = ArrayAdapter.createFromResource(mContext, R.array.priority, android.R.layout.simple_spinner_item); spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mPriorityView = (Spinner) mView.findViewById(R.id.task_detail_priority); mPriorityView.setAdapter(spinnerAdapter); mPriorityView.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override/*from www. j a v a2 s . com*/ public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { mPriority = (String) parent.getItemAtPosition(position); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); if (mNewTask) { // Make "normal" the default priority. // the position for "normal" should be 1 mPriorityView.setSelection(1); mPriority = mPriorityView.getSelectedItem().toString(); } Button saveView = (Button) mView.findViewById(R.id.save); saveView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { saveData(); if (mNewTask) { dismiss(); } } }); if (!mBackFromRotation && !mNewTask) { mCursorLoader = getActivity().getSupportLoaderManager().initLoader(URL_LOADER, null, this); } return mView; }
From source file:org.gnucash.android.ui.accounts.ExportDialogFragment.java
/** * Collects references to the UI elements and binds click listeners *///w ww. j a v a 2s. c o m private void bindViews() { View v = getView(); mDestinationSpinner = (Spinner) v.findViewById(R.id.spinner_export_destination); ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(getActivity(), R.array.export_destinations, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mDestinationSpinner.setAdapter(adapter); SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(getActivity()); mExportAllCheckBox = (CheckBox) v.findViewById(R.id.checkbox_export_all); mExportAllCheckBox .setChecked(sharedPrefs.getBoolean(getString(R.string.key_export_all_transactions), false)); mDeleteAllCheckBox = (CheckBox) v.findViewById(R.id.checkbox_post_export_delete); mDeleteAllCheckBox.setChecked( sharedPrefs.getBoolean(getString(R.string.key_delete_transactions_after_export), false)); mSaveButton = (Button) v.findViewById(R.id.btn_save); mSaveButton.setText(R.string.btn_export); mCancelButton = (Button) v.findViewById(R.id.btn_cancel); mCancelButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dismiss(); } }); mSaveButton.setOnClickListener(new ExportClickListener()); }
From source file:uk.org.rivernile.edinburghbustracker.android.fragments.general.AddTimeAlertFragment.java
/** * {@inheritDoc}/*w ww. java 2 s . co m*/ */ @Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { final View v = inflater.inflate(R.layout.addtimealert, container, false); btnOkay = (Button) v.findViewById(R.id.btnOkay); txtServices = (TextView) v.findViewById(R.id.txtTimeAlertServices); txtTimeDialogStop = (TextView) v.findViewById(R.id.txtTimeDialogStop); btnOkay.setOnClickListener(new OnClickListener() { @Override public void onClick(final View v) { // Add the alert. alertMan.addTimeAlert(stopCode, selectedServices, timeTrigger); // Tell the underlying Activity that a new alert has been added. callbacks.onTimeAlertAdded(); } }); // Set up the spinner. final Spinner spinner = (Spinner) v.findViewById(R.id.time_time_select); final ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(getActivity(), R.array.addtimealert_array, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter); spinner.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(final AdapterView<?> parent, final View view, final int pos, final long id) { switch (pos) { case 0: timeTrigger = 1; break; case 1: timeTrigger = 2; break; case 2: timeTrigger = 5; break; case 3: timeTrigger = 10; break; case 4: timeTrigger = 15; break; case 5: timeTrigger = 20; break; case 6: timeTrigger = 25; break; case 7: timeTrigger = 30; break; default: timeTrigger = 0; break; } } @Override public void onNothingSelected(final AdapterView parent) { timeTrigger = 0; } }); Button btn = (Button) v.findViewById(R.id.btnCancel); btn.setOnClickListener(new OnClickListener() { @Override public void onClick(final View v) { // Tell the underlying Activity that the user has cancelled. callbacks.onCancelAddTimeAlert(); } }); btn = (Button) v.findViewById(R.id.btnAlertTimeServices); if (services != null && services.length > 0) { btn.setOnClickListener(new OnClickListener() { @Override public void onClick(final View v) { callbacks.onShowServicesChooser(services, selectedServices, getString(R.string.addtimealert_services_title)); } }); } else { btn.setEnabled(false); } btn = (Button) v.findViewById(R.id.btnLimitations); btn.setOnClickListener(new OnClickListener() { @Override public void onClick(final View v) { callbacks.onShowTimeAlertLimitations(); } }); // Set a piece of informative text with the stopCode, stopName and // locality (if available). final String locality = bsd.getLocalityForStopCode(stopCode); final String name; if (locality != null) { name = getString(R.string.busstop_locality_coloured, bsd.getNameForBusStop(stopCode), locality, stopCode); } else { name = getString(R.string.busstop_coloured, bsd.getNameForBusStop(stopCode), stopCode); } txtTimeDialogStop.setText(Html.fromHtml(getString(R.string.addtimealert_busstop, name))); // Force a refresh of the TextView that shows the services that have // been chosen. onServicesChosen(selectedServices); return v; }
From source file:mobi.daytoday.DayToDay.BetweenDatesFragment.java
/** * Create the view, set up our key objects and assign the listeners *///ww w . j a v a 2 s .c om @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.between_dates, container, false); firstDateInput = (EditText) v.findViewById(R.id.first_date_input); firstDateInput.setFocusable(true); firstDateInput.requestFocus(); firstDateInput.requestFocusFromTouch(); firstDateInput.setOnEditorActionListener(dateEditListener); firstDateInput.setOnTouchListener(handlePhysicalKeyboardListener); firstDateInput.setOnFocusChangeListener(editTextLosesFocusListener); secondDateInput = (EditText) v.findViewById(R.id.second_date_input); secondDateInput.setOnEditorActionListener(dateEditListener); secondDateInput.setOnTouchListener(handlePhysicalKeyboardListener); secondDateInput.setOnFocusChangeListener(editTextLosesFocusListener); answer = (TextView) v.findViewById(R.id.between_dates_answer); answerInSpinner = (Spinner) v.findViewById(R.id.answer_in_spinner); ArrayAdapter<CharSequence> answerInAdapter = ArrayAdapter.createFromResource(getActivity(), R.array.answer_in_array, android.R.layout.simple_spinner_item); answerInAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); answerInSpinner.setAdapter(answerInAdapter); answerInSpinner.setOnItemSelectedListener(answerInSelectedListener); firstDateSelect = (ImageButton) v.findViewById(R.id.first_date_select); firstDateSelect.setOnClickListener(firstDateListener); secondDateSelect = (ImageButton) v.findViewById(R.id.second_date_select); secondDateSelect.setOnClickListener(secondDateListener); resetButton = (Button) v.findViewById(R.id.between_dates_reset_button); resetButton.setOnClickListener(resetListener); resetButton.setVisibility(View.INVISIBLE); resetVisible = false; return v; }
From source file:com.github.riotopsys.malforandroid2.fragment.AnimeDetailFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); watchedStatus.setAdapter(ArrayAdapter.createFromResource(getActivity(), R.array.anime_status_options, android.R.layout.simple_spinner_dropdown_item)); watchedStatus.setOnItemSelectedListener(this); scoreStatus.setAdapter(ArrayAdapter.createFromResource(getActivity(), R.array.anime_score_options, android.R.layout.simple_spinner_dropdown_item)); addSpinner.setAdapter(ArrayAdapter.createFromResource(getActivity(), R.array.anime_status_options, android.R.layout.simple_spinner_dropdown_item)); scoreStatus.setOnItemSelectedListener(this); singleAnimeLoader = getLoaderManager().initLoader(0, null, this); singleAnimeLoader.forceLoad();// w ww .j a v a 2 s .c o m plusOne.setOnClickListener(this); watchedPannel.setOnClickListener(this); prequel.setOnClickListener(this); sequel.setOnClickListener(this); sideStory.setOnClickListener(this); spinOffs.setOnClickListener(this); summaries.setOnClickListener(this); alternativeVersions.setOnClickListener(this); mangaAdaptations.setOnClickListener(this); addButton.setOnClickListener(this); synopsysContainer.setOnTouchListener(this); }
From source file:org.onebusaway.android.ui.TripPlanFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Init Google Play Services as early as possible in the Fragment lifecycle to give it time if (GooglePlayServicesUtil.isGooglePlayServicesAvailable(getActivity()) == ConnectionResult.SUCCESS) { mGoogleApiClient = LocationUtils.getGoogleApiClientWithCallbacks(getContext()); mGoogleApiClient.connect();//w ww .java 2 s . c o m } Bundle bundle = getArguments(); mBuilder = new TripRequestBuilder(bundle); final View view = inflater.inflate(R.layout.fragment_trip_plan, container, false); setHasOptionsMenu(true); mFromAddressTextArea = (AutoCompleteTextView) view.findViewById(R.id.fromAddressTextArea); mToAddressTextArea = (AutoCompleteTextView) view.findViewById(R.id.toAddressTextArea); mFromCurrentLocationImageButton = (ImageButton) view.findViewById(R.id.fromCurrentLocationImageButton); mToCurrentLocationImageButton = (ImageButton) view.findViewById(R.id.toCurrentLocationImageButton); mDate = (Spinner) view.findViewById(R.id.date); mDateAdapter = new ArrayAdapter(getActivity(), R.layout.simple_list_item); mDate.setAdapter(mDateAdapter); mTime = (Spinner) view.findViewById(R.id.time); mTimeAdapter = new ArrayAdapter(getActivity(), R.layout.simple_list_item); mTime.setAdapter(mTimeAdapter); mLeavingChoice = (Spinner) view.findViewById(R.id.leavingChoiceSpinner); mLeavingChoiceAdapter = ArrayAdapter.createFromResource(getContext(), R.array.trip_plan_leaving_arriving_array, R.layout.simple_list_item); mLeavingChoiceAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mLeavingChoice.setAdapter(mLeavingChoiceAdapter); // Set mLeavingChoice onclick adapter in onResume() so we do not fire it when setting it final TimePickerDialog.OnTimeSetListener timeCallback = new TimePickerDialog.OnTimeSetListener() { @Override public void onTimeSet(TimePicker view, int hour, int minute) { mMyCalendar.set(Calendar.HOUR_OF_DAY, hour); mMyCalendar.set(Calendar.MINUTE, minute); resetDateTimeLabels(); mBuilder.setDateTime(mMyCalendar); checkRequestAndSubmit(); } }; final DatePickerDialog.OnDateSetListener dateCallback = new DatePickerDialog.OnDateSetListener() { @Override public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) { mMyCalendar.set(Calendar.YEAR, year); mMyCalendar.set(Calendar.MONTH, monthOfYear); mMyCalendar.set(Calendar.DAY_OF_MONTH, dayOfMonth); resetDateTimeLabels(); mBuilder.setDateTime(mMyCalendar); checkRequestAndSubmit(); } }; mDate.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent motionEvent) { if (motionEvent.getAction() == MotionEvent.ACTION_UP) { new DatePickerDialog(view.getContext(), dateCallback, mMyCalendar.get(Calendar.YEAR), mMyCalendar.get(Calendar.MONTH), mMyCalendar.get(Calendar.DAY_OF_MONTH)).show(); } return true; } }); mTime.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent motionEvent) { if (motionEvent.getAction() == MotionEvent.ACTION_UP) { new TimePickerDialog(view.getContext(), timeCallback, mMyCalendar.get(Calendar.HOUR_OF_DAY), mMyCalendar.get(Calendar.MINUTE), false).show(); } return true; } }); ImageButton resetTimeButton = (ImageButton) view.findViewById(R.id.resetTimeImageButton); resetTimeButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mMyCalendar = Calendar.getInstance(); mBuilder.setDateTime(mMyCalendar); resetDateTimeLabels(); checkRequestAndSubmit(); } }); setUpAutocomplete(mFromAddressTextArea, USE_FROM_ADDRESS); setUpAutocomplete(mToAddressTextArea, USE_TO_ADDRESS); mToCurrentLocationImageButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mToAddressTextArea.setText(getString(R.string.tripplanner_current_location)); mToAddress = makeAddressFromLocation(); mBuilder.setTo(mToAddress); checkRequestAndSubmit(); } }); mFromCurrentLocationImageButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mFromAddressTextArea.setText(getString(R.string.tripplanner_current_location)); mFromAddress = makeAddressFromLocation(); mBuilder.setFrom(mFromAddress); checkRequestAndSubmit(); } }); // Start: default from address is Current Location, to address is unset return view; }
From source file:de.spiritcroc.ownlog.ui.fragment.LogFilterEditFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { final Activity activity = getActivity(); AlertDialog.Builder builder = new AlertDialog.Builder(activity); final View view = activity.getLayoutInflater().inflate(R.layout.log_filter_edit_item, null); mEditName = (EditText) view.findViewById(R.id.name_edit); mSpinSortOrder = (Spinner) view.findViewById(R.id.sort_order_spin); mCheckStrictFilterTags = (CheckBox) view.findViewById(R.id.tags_strict_check); mStrictFilterTagsInfoNoTags = view.findViewById(R.id.text_view_tags_strict_no_tags); mStrictFilterTagsInfoTags = view.findViewById(R.id.text_view_tags_strict_tags); mEditTagsView = (EditTagsView) view.findViewById(R.id.edit_tags_view); mEditTagsView.setTagsProvider(mTagsProvider); mEditTagsView.setAvailableTagsFilter(mAvailableTagsFilter); mEditExcludedTagsView = (EditTagsView) view.findViewById(R.id.edit_excluded_tags_view); mEditExcludedTagsView.setTagsProvider(mExcludedTagsProvider); mEditExcludedTagsView.setAvailableTagsFilter(mAvailableTagsFilter); View.OnClickListener strictFilterInfoClickListener = new View.OnClickListener() { @Override/* w ww . java 2 s .com*/ public void onClick(View view) { mCheckStrictFilterTags.toggle(); } }; mStrictFilterTagsInfoNoTags.setOnClickListener(strictFilterInfoClickListener); mStrictFilterTagsInfoTags.setOnClickListener(strictFilterInfoClickListener); mSortOrderValues = getResources().getStringArray(R.array.edit_log_filter_sort_order_values); mSpinSortOrder.setAdapter(ArrayAdapter.createFromResource(activity, R.array.edit_log_filter_sort_order_entries, R.layout.support_simple_spinner_dropdown_item)); mSpinSortOrder.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { mSortOrder = i; } @Override public void onNothingSelected(AdapterView<?> adapterView) { } }); mInitName = getString(R.string.log_filter_default_new_name); mInitSortOrder = mSortOrderValues[0]; boolean restoredValues = restoreValues(savedInstanceState); builder.setTitle(mAddItem ? R.string.title_log_filter_add : R.string.title_log_filter_edit).setView(view) .setPositiveButton(R.string.dialog_ok, null) .setNegativeButton(R.string.dialog_cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // Only dismiss } }); if (!mAddItem) { builder.setNeutralButton(R.string.dialog_delete, null); } final AlertDialog alertDialog = builder.create(); alertDialog.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialogInterface) { alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { saveChanges(); } }); if (!mAddItem) { alertDialog.getButton(DialogInterface.BUTTON_NEUTRAL) .setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { promptDelete(); } }); } } }); if (!restoredValues) { loadContent(); if (mAddItem) { initValues(alertDialog); } } return alertDialog; }
From source file:github.daneren2005.dsub.activity.EditPlayActionActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setTitle(R.string.tasker_start_playing_title); setContentView(R.layout.edit_play_action); final Activity context = this; doNothing = context.getResources().getString(R.string.tasker_edit_do_nothing); shuffleCheckbox = (CheckBox) findViewById(R.id.edit_shuffle_checkbox); shuffleCheckbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override/*from w w w . j ava 2 s. c o m*/ public void onCheckedChanged(CompoundButton view, boolean isChecked) { startYearCheckbox.setEnabled(isChecked); endYearCheckbox.setEnabled(isChecked); genreButton.setEnabled(isChecked); } }); startYearCheckbox = (CheckBox) findViewById(R.id.edit_start_year_checkbox); startYearBox = (EditText) findViewById(R.id.edit_start_year); // Disable/enable number box if checked startYearCheckbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton view, boolean isChecked) { startYearBox.setEnabled(isChecked); } }); endYearCheckbox = (CheckBox) findViewById(R.id.edit_end_year_checkbox); endYearBox = (EditText) findViewById(R.id.edit_end_year); endYearCheckbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton view, boolean isChecked) { endYearBox.setEnabled(isChecked); } }); genreButton = (Button) findViewById(R.id.edit_genre_spinner); genreButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { new LoadingTask<List<Genre>>(context, true) { @Override protected List<Genre> doInBackground() throws Throwable { MusicService musicService = MusicServiceFactory.getMusicService(context); return musicService.getGenres(false, context, this); } @Override protected void done(final List<Genre> genres) { List<String> names = new ArrayList<String>(); String blank = context.getResources().getString(R.string.select_genre_blank); names.add(doNothing); names.add(blank); for (Genre genre : genres) { names.add(genre.getName()); } final List<String> finalNames = names; AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setTitle(R.string.shuffle_pick_genre).setItems( names.toArray(new CharSequence[names.size()]), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { if (which == 1) { genreButton.setText(""); } else { genreButton.setText(finalNames.get(which)); } } }); AlertDialog dialog = builder.create(); dialog.show(); } @Override protected void error(Throwable error) { String msg; if (error instanceof OfflineException || error instanceof ServerTooOldException) { msg = getErrorMessage(error); } else { msg = context.getResources().getString(R.string.playlist_error) + " " + getErrorMessage(error); } Util.toast(context, msg, false); } }.execute(); } }); genreButton.setText(doNothing); offlineSpinner = (Spinner) findViewById(R.id.edit_offline_spinner); ArrayAdapter<CharSequence> offlineAdapter = ArrayAdapter.createFromResource(this, R.array.editServerOptions, android.R.layout.simple_spinner_item); offlineAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); offlineSpinner.setAdapter(offlineAdapter); // Setup default for everything Bundle extras = getIntent().getBundleExtra(Constants.TASKER_EXTRA_BUNDLE); if (extras != null) { if (extras.getBoolean(Constants.INTENT_EXTRA_NAME_SHUFFLE)) { shuffleCheckbox.setChecked(true); } String startYear = extras.getString(Constants.PREFERENCES_KEY_SHUFFLE_START_YEAR, null); if (startYear != null) { startYearCheckbox.setEnabled(true); startYearBox.setText(startYear); } String endYear = extras.getString(Constants.PREFERENCES_KEY_SHUFFLE_END_YEAR, null); if (endYear != null) { endYearCheckbox.setEnabled(true); endYearBox.setText(endYear); } String genre = extras.getString(Constants.PREFERENCES_KEY_SHUFFLE_GENRE, doNothing); if (genre != null) { genreButton.setText(genre); } int offline = extras.getInt(Constants.PREFERENCES_KEY_OFFLINE, 0); if (offline != 0) { offlineSpinner.setSelection(offline); } } drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED); }
From source file:nrec.basil.wimuconsole.SensorSettingsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_sensor_settings); // Set up the action bar to show a dropdown list which will // contain the various sensors that can be configured. Some // sensors are local (camera) some are remote bluetooth devices // (IMU, Barometer etc.) final ActionBar actionBar = getActionBar(); actionBar.setDisplayShowTitleEnabled(false); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); // Set up the dropdown list navigation in the action bar. actionBar.setListNavigationCallbacks( // Specify a SpinnerAdapter to populate the dropdown list. new ArrayAdapter<String>(actionBar.getThemedContext(), android.R.layout.simple_list_item_1, android.R.id.text1, getResources().getStringArray(R.array.sensors_list)), this); // Specify a SpinnerAdapter to populate the wIMU list ArrayAdapter<CharSequence> imuAdapter = ArrayAdapter.createFromResource(this, R.array.wimu_list, android.R.layout.simple_spinner_item); imuAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); imuSpinner = (Spinner) findViewById(R.id.wimulist); imuSpinner.setAdapter(imuAdapter);/* ww w. j a v a 2 s . c o m*/ // Load the BASIL start/stop/reset commands InputStream input = getResources().openRawResource(R.raw.basilstart); try { input.read(basilStart, 0, 26); } catch (IOException e) { Log.e(TAG, "Could not read BASIL start command", e); } input = getResources().openRawResource(R.raw.basilstop); try { input.read(basilStop, 0, 26); } catch (IOException e) { Log.e(TAG, "Could not read BASIL stop command", e); } input = getResources().openRawResource(R.raw.basilreset); try { input.read(basilReset, 0, 26); } catch (IOException e) { Log.e(TAG, "Could not read BASIL reset command", e); } // Get the default filename for logging EditText logfilename = (EditText) findViewById(R.id.logfilename); mLogFileName = logfilename.toString(); // Get local Bluetooth adapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); // If the adapter is null, then Bluetooth is not supported if (mBluetoothAdapter == null) { Toast.makeText(this, "Bluetooth is not available", Toast.LENGTH_LONG).show(); finish(); return; } }
From source file:mp.paschalis.EditBookActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); app = (App) getApplication();/* www . j av a 2 s . c om*/ setContentView(R.layout.activity_edit_book); getSupportActionBar().setDisplayHomeAsUpEnabled(true); // Get arguments, to determine who opened this activity final Bundle extras = getIntent().getExtras(); try { fromBookSearch = extras.getBoolean(App.ExtrasForEditBookActivityFromBookSearch); } catch (Exception e) { fromBookSearch = false; } // Set the layout's data // Get layout's Data bookISBN = (TextView) findViewById(R.id.textViewBookISBN); bookTitle = (TextView) findViewById(R.id.textViewBookTitle); bookAuthors = (TextView) findViewById(R.id.textViewBookAuthors); bookPublishedYear = (TextView) findViewById(R.id.textViewBookPublishedYear); bookPageCount = (TextView) findViewById(R.id.textViewBookPageCount); bookDateOfInsert = (TextView) findViewById(R.id.textViewBookDateOfInsert); bookCoverImage = (ImageView) findViewById(R.id.imageViewBookCover); bookLanguage = (TextView) findViewById(R.id.textViewBookLanguage); textViewCheckYourBooks = (TextView) findViewById(R.id.textViewCheckYourBooks); TextView tvnocover = (TextView) findViewById(R.id.textViewNoCover); ProgressBar pb = (ProgressBar) findViewById(R.id.progressBarLoadCover); // show The Image and save it to Library ImageLoader.DataClassDisplayBookCover bk = new ImageLoader.DataClassDisplayBookCover(); bk.iv = bookCoverImage; bk.isCover = true; bk.pb = pb; bk.tv = tvnocover; bk.book = app.selectedBook; App.imageLoader.DisplayCover(bk); // Assign the appropriate data from our alert object above bookISBN.setText(app.selectedBook.isbn); bookTitle.setText(app.selectedBook.title); bookAuthors.setText(app.selectedBook.authors); bookPublishedYear.setText(Integer.valueOf(app.selectedBook.publishedYear).toString()); bookPageCount.setText(Integer.valueOf(app.selectedBook.pageCount).toString()); bookDateOfInsert .setText(App.makeTimeStampHumanReadble(getApplicationContext(), app.selectedBook.dateOfInsert)); bookLanguage.setText(app.selectedBook.lang); progressBarChangeStatusOfBook = (ProgressBar) findViewById(R.id.progressBarChangeBookStatus); progressBarLentReturnButton = (ProgressBar) findViewById(R.id.progressBarReturnLentBook); progressBarLentDeleteButton = (ProgressBar) findViewById(R.id.progressBarBookDeleteButton); buttonDeleteBook = (Button) findViewById(R.id.buttonBookDelete); buttonLentReturnBook = (Button) findViewById(R.id.buttonLentReturnBook); spinnerEditBookStatus = (Spinner) findViewById(R.id.spinnerBookStatus); // Create adapter for the Spinner adapter = ArrayAdapter.createFromResource(this, R.array.ArrayBookSetStatus, 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 spinnerEditBookStatus.setAdapter(adapter); getStatusDefaultValue(); spinnerEditBookStatus.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) { if (booleanFirstInit) { booleanFirstInit = false; return; } // your code here new AsyncTaskChangeStatusOfBook().execute( App.getBookStatusCode((String) (adapter.getItem(position)), EditBookActivity.this)); } @Override public void onNothingSelected(AdapterView<?> parentView) { } }); // Hybrid button: Lent/Return a book buttonLentReturnBook.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { { // Lent the book if (buttonLentReturnBook.getText().toString().equals(getString(R.string.lent))) { // Send ISBN As Argument Intent i = new Intent(getApplicationContext(), LentBookActivity.class); i.putExtra(App.ExtrasForLentBookActivityISBN, bookISBN.getText().toString()); EditBookActivity.this.startActivity(i); } // Return the book else { { AlertDialog.Builder alert = new AlertDialog.Builder(EditBookActivity.this); alert.setTitle(R.string.msgIsItReturnedToYou_); alert.setIcon(R.drawable.ic_menu_forward); alert.setNegativeButton(R.string.no, new android.content.DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); alert.setPositiveButton(R.string.yes, new android.content.DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // Return the book new AsyncTaskReturnABook().execute(app.selectedBook.isbn); } }); alert.show(); } } } } });// End of Lent/Return Button! // Delete Button buttonDeleteBook.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { { AlertDialog.Builder alert = new AlertDialog.Builder(EditBookActivity.this); alert.setTitle(R.string.msgAreYouSureDelBOok_); alert.setIcon(R.drawable.ic_dialog_alert_holo_light); alert.setNegativeButton(R.string.no, new android.content.DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); alert.setPositiveButton(R.string.yes, new android.content.DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // Return the book new AsyncTaskDeleteABook().execute(app.selectedBook.isbn); } }); alert.show(); } } }); }