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.rui.ruitime.AppUsageStatisticsFragment.java
@Override public void onViewCreated(View rootView, Bundle savedInstanceState) { super.onViewCreated(rootView, savedInstanceState); mUsageListAdapter = new AppUsageListAdapter(); mRecyclerView = (RecyclerView) rootView.findViewById(R.id.recyclerview_app_usage); mLayoutManager = mRecyclerView.getLayoutManager(); mRecyclerView.scrollToPosition(0);//from ww w .j a v a 2 s . co m mRecyclerView.setAdapter(mUsageListAdapter); mOpenUsageSettingButton = (Button) rootView.findViewById(R.id.button_open_usage_setting); mTimeSpanSpinner = (Spinner) rootView.findViewById(R.id.spinner_time_span); SpinnerAdapter timeSpanSpinnerAdapter = ArrayAdapter.createFromResource(getActivity(), R.array.action_list, android.R.layout.simple_spinner_dropdown_item); mTimeSpanSpinner.setAdapter(timeSpanSpinnerAdapter); final String[] intervalStrs = getResources().getStringArray(R.array.action_list); final String[] criteriaStrs = getResources().getStringArray(R.array.sort_by_list); mTimeSpanSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { itemPosOfTimeSpanSpinner = position; StatsUsageInterval statsUsageInterval = StatsUsageInterval.getValue(intervalStrs[position]); if (statsUsageInterval != null) { List<UsageStats> usageStatsList = getUsageStatistics(statsUsageInterval.mInterval); if (criteriaStrs[itemPosOfSortSpinner].equals("Total duration")) { updateAppsList(usageStatsList, 0); } else if (criteriaStrs[itemPosOfSortSpinner].equals("Alphabetical")) { updateAppsList(usageStatsList, 1); } } } @Override public void onNothingSelected(AdapterView<?> parent) { } }); mSortSpinner = (Spinner) rootView.findViewById(R.id.spinner_sort); SpinnerAdapter SortSpinnerAdapter = ArrayAdapter.createFromResource(getActivity(), R.array.sort_by_list, android.R.layout.simple_spinner_dropdown_item); mSortSpinner.setAdapter(SortSpinnerAdapter); mSortSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { // Get the usageStatsList according to StatsUsageInterval selection first // Then according to the criteria, handle the list sorting and update the list itemPosOfSortSpinner = position; StatsUsageInterval statsUsageInterval = StatsUsageInterval .getValue(intervalStrs[itemPosOfTimeSpanSpinner]); if (statsUsageInterval != null) { List<UsageStats> usageStatsList = getUsageStatistics(statsUsageInterval.mInterval); if (criteriaStrs[position].equals("Total duration")) { //Collections.sort(usageStatsList, new TotalDurationUsedComparatorDesc()); updateAppsList(usageStatsList, 0); } else if (criteriaStrs[position].equals("Alphabetical")) { updateAppsList(usageStatsList, 1); } } } @Override public void onNothingSelected(AdapterView<?> parent) { } }); }
From source file:com.example.android.scopeddirectoryaccess.ScopedDirectoryAccessFragment.java
@Override public void onViewCreated(final View rootView, Bundle savedInstanceState) { super.onViewCreated(rootView, savedInstanceState); mCurrentDirectoryTextView = (TextView) rootView.findViewById(R.id.textview_current_directory); mNothingInDirectoryTextView = (TextView) rootView.findViewById(R.id.textview_nothing_in_directory); mPrimaryVolumeNameTextView = (TextView) rootView.findViewById(R.id.textview_primary_volume_name); // Set onClickListener for the primary volume Button openPictureButton = (Button) rootView.findViewById(R.id.button_open_directory_primary_volume); openPictureButton.setOnClickListener(new View.OnClickListener() { @Override//from w ww .j a v a 2 s . com public void onClick(View view) { String selected = mDirectoriesSpinner.getSelectedItem().toString(); String directoryName = getDirectoryName(selected); StorageVolume storageVolume = mStorageManager.getPrimaryStorageVolume(); Intent intent = storageVolume.createAccessIntent(directoryName); startActivityForResult(intent, OPEN_DIRECTORY_REQUEST_CODE); } }); // Set onClickListener for the external volumes if exists List<StorageVolume> storageVolumes = mStorageManager.getStorageVolumes(); LinearLayout containerVolumes = (LinearLayout) mActivity.findViewById(R.id.container_volumes); for (final StorageVolume volume : storageVolumes) { String volumeDescription = volume.getDescription(mActivity); if (volume.isPrimary()) { // Primary volume area is already added... if (volumeDescription != null) { // ...but with a default name: set it to the real name when available. mPrimaryVolumeNameTextView.setText(volumeDescription); } continue; } LinearLayout volumeArea = (LinearLayout) mActivity.getLayoutInflater().inflate(R.layout.volume_entry, containerVolumes); TextView volumeName = (TextView) volumeArea.findViewById(R.id.textview_volume_name); volumeName.setText(volumeDescription); Button button = (Button) volumeArea.findViewById(R.id.button_open_directory); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { String selected = mDirectoriesSpinner.getSelectedItem().toString(); String directoryName = getDirectoryName(selected); Intent intent = volume.createAccessIntent(directoryName); startActivityForResult(intent, OPEN_DIRECTORY_REQUEST_CODE); } }); } RecyclerView recyclerView = (RecyclerView) rootView.findViewById(R.id.recyclerview_directory_entries); if (savedInstanceState != null) { mDirectoryEntries = savedInstanceState.getParcelableArrayList(DIRECTORY_ENTRIES_KEY); mCurrentDirectoryTextView.setText(savedInstanceState.getString(SELECTED_DIRECTORY_KEY)); mAdapter = new DirectoryEntryAdapter(mDirectoryEntries); if (mAdapter.getItemCount() == 0) { mNothingInDirectoryTextView.setVisibility(View.VISIBLE); } } else { mDirectoryEntries = new ArrayList<>(); mAdapter = new DirectoryEntryAdapter(); } recyclerView.setAdapter(mAdapter); recyclerView.setLayoutManager(new LinearLayoutManager(getActivity())); mDirectoriesSpinner = (Spinner) rootView.findViewById(R.id.spinner_directories); ArrayAdapter<CharSequence> directoriesAdapter = ArrayAdapter.createFromResource(getActivity(), R.array.directories, android.R.layout.simple_spinner_item); directoriesAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mDirectoriesSpinner.setAdapter(directoriesAdapter); }
From source file:com.tundem.alternativefindr.AlternativefindrActivity.java
public void init_actionbar() { ActionBar ab = getSupportActionBar(); ab.setDisplayShowTitleEnabled(false); ab.setDisplayHomeAsUpEnabled(false); ab.setDisplayUseLogoEnabled(true);/* w w w . ja v a 2 s .c o m*/ ab.setListNavigationCallbacks(ArrayAdapter.createFromResource(this, R.array.listValues_sections, R.layout.sherlock_spinner_dropdown_item), navigationListener); if (ab.getNavigationMode() != ActionBar.NAVIGATION_MODE_LIST) { ab.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); } }
From source file:cz.maresmar.sfm.view.portal.PortalDetailFragment.java
@Override public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_portal_detail, container, false); mNameText = view.findViewById(R.id.nameText); mRefText = view.findViewById(R.id.refText); // Plugin options mPluginSpinner = view.findViewById(R.id.pluginSpinner); // Security options mSecuritySpinner = view.findViewById(R.id.securitySpinner); //noinspection ConstantConditions mSecuritySpinnerAdapter = ArrayAdapter.createFromResource(getContext(), R.array.connection_security_values, R.layout.support_simple_spinner_dropdown_item); mSecuritySpinner.setAdapter(mSecuritySpinnerAdapter); // New menu notification mNewMenuNotificationCheckBox = view.findViewById(R.id.portalNewMenuNotify); // Gets the MapView from the XML layout and creates it mMapView = view.findViewById(R.id.mapView); mMapView.onCreate(savedInstanceState); // Gets to GoogleMap from the MapView and does initialization stuff mMapView.getMapAsync(map -> {/*from w w w . j a v a2 s . c om*/ // Needs to call MapsInitializer before doing any CameraUpdateFactory calls //noinspection ConstantConditions MapsInitializer.initialize(getContext()); // Updates the location and zoom of the MapView to Jihlava, CZ CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(DEFAULT_LOCATION, 10); map.animateCamera(cameraUpdate); }); // Pick location button view.findViewById(R.id.pickButton).setOnClickListener(locationView -> { Timber.i("Place picker intent request fired"); PlacePicker.IntentBuilder builder = new PlacePicker.IntentBuilder(); try { //noinspection ConstantConditions startActivityForResult(builder.build(getActivity()), PLACE_PICKER_REQUEST); } catch (GooglePlayServicesRepairableException | GooglePlayServicesNotAvailableException e) { boolean serviceAvailable = SfmApp.checkPlayServices(getActivity()); Timber.e(e, "Cannot start Place picker intent, (Google play service available = %b)", serviceAvailable); e.printStackTrace(); } }); // Remove location button mRemoteButton = view.findViewById(R.id.remoteButton); mRemoteButton.setOnClickListener(buttonView -> removeLocation()); return view; }
From source file:com.mbientlab.metawear.app.popup.AccelerometerSettings.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { getDialog().setTitle("Accelerometer Settings"); Spinner spinnerObj;/*www. j a v a 2 s. c o m*/ spinnerObj = (Spinner) view.findViewById(R.id.spinner1); spinnerObj.setAdapter(new ArrayAdapter<TapType>(getActivity(), R.layout.command_row, R.id.command_name, TapType.values())); spinnerObj.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { accelConfig.modifyTapType(position); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); spinnerObj.setSelection(accelConfig.tapTypePos()); spinnerObj = (Spinner) view.findViewById(R.id.spinner2); spinnerObj.setAdapter( new ArrayAdapter<Axis>(getActivity(), R.layout.command_row, R.id.command_name, Axis.values())); spinnerObj.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { accelConfig.modifyTapAxis(position); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); spinnerObj.setSelection(accelConfig.tapAxisPos()); spinnerObj = (Spinner) view.findViewById(R.id.spinner3); spinnerObj.setAdapter( new ArrayAdapter<Axis>(getActivity(), R.layout.command_row, R.id.command_name, Axis.values())); spinnerObj.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { accelConfig.modifyShakeAxis(position); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); spinnerObj.setSelection(accelConfig.shakeAxisPos()); spinnerObj = (Spinner) view.findViewById(R.id.spinner4); spinnerObj.setAdapter(new ArrayAdapter<FullScaleRange>(getActivity(), R.layout.command_row, R.id.command_name, FullScaleRange.values())); spinnerObj.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { accelConfig.modifyDataRange(position); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); spinnerObj.setSelection(accelConfig.fsrPos()); spinnerObj = (Spinner) view.findViewById(R.id.spinner5); spinnerObj.setAdapter(new ArrayAdapter<OutputDataRate>(getActivity(), R.layout.command_row, R.id.command_name, OutputDataRate.values())); spinnerObj.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { accelConfig.modifySamplingRate(position); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); spinnerObj.setSelection(accelConfig.odrPos()); spinnerObj = (Spinner) view.findViewById(R.id.spinner6); spinnerObj.setAdapter(new ArrayAdapter<String>(getActivity(), R.layout.command_row, R.id.command_name, new String[] { "Free Fall", "Motion" })); spinnerObj.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { accelConfig.modifyMovementType(position); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); spinnerObj.setSelection(accelConfig.movementPos()); spinnerObj = (Spinner) view.findViewById(R.id.spinner7); spinnerObj.setAdapter(ArrayAdapter.createFromResource(getActivity(), R.array.firmware_version_array, android.R.layout.simple_spinner_item)); spinnerObj.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { accelConfig.modifyFirmwareVersion(position); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); spinnerObj.setSelection(accelConfig.firmwarePos()); }
From source file:eu.power_switch.gui.fragment.settings.GeneralSettingsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { rootView = inflater.inflate(R.layout.fragment_general_settings, container, false); final Fragment fragment = this; CompoundButton.OnCheckedChangeListener onCheckedChangeListener = new CompoundButton.OnCheckedChangeListener() { @Override/*from w w w .jav a 2s. com*/ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { switch (buttonView.getId()) { case R.id.checkBox_autoDiscover: SmartphonePreferencesHandler.setAutoDiscover(isChecked); break; case R.id.checkBox_autoCollapseRooms: SmartphonePreferencesHandler.setAutoCollapseRooms(isChecked); break; case R.id.checkBox_autoCollapseTimers: SmartphonePreferencesHandler.setAutoCollapseTimers(isChecked); break; case R.id.checkBox_showRoomAllOnOffButtons: SmartphonePreferencesHandler.setShowRoomAllOnOff(isChecked); break; case R.id.checkBox_hideAddFAB: SmartphonePreferencesHandler.setUseOptionsMenuInsteadOfFAB(isChecked); break; case R.id.checkBox_vibrateOnButtonPress: SmartphonePreferencesHandler.setVibrateOnButtonPress(isChecked); if (isChecked) { vibrationDurationLayout.setVisibility(View.VISIBLE); } else { vibrationDurationLayout.setVisibility(View.GONE); } break; case R.id.checkBox_highlightLastActivatedButton: SmartphonePreferencesHandler.setHighlightLastActivatedButton(isChecked); // force receiver widget update ReceiverWidgetProvider.forceWidgetUpdate(getContext()); break; default: break; } } }; // setup hidden developer menu TextView generalSettingsTextView = (TextView) rootView.findViewById(R.id.TextView_generalSettings); generalSettingsTextView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Calendar currentTime = Calendar.getInstance(); if (devMenuFirstClickTime != null) { Calendar latestTime = Calendar.getInstance(); latestTime.setTime(devMenuFirstClickTime.getTime()); latestTime.add(Calendar.SECOND, 5); if (currentTime.after(latestTime)) { devMenuClickCounter = 0; } } devMenuClickCounter++; if (devMenuClickCounter == 1) { devMenuFirstClickTime = currentTime; } if (devMenuClickCounter >= 5) { devMenuClickCounter = 0; DeveloperOptionsDialog developerOptionsDialog = new DeveloperOptionsDialog(); developerOptionsDialog.show(getActivity().getSupportFragmentManager(), null); } } }); startupDefaultTab = (Spinner) rootView.findViewById(R.id.spinner_startupDefaultTab); ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(getContext(), R.array.main_tab_names, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); startupDefaultTab.setAdapter(adapter); startupDefaultTab.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { SmartphonePreferencesHandler.setStartupDefaultTab(position); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); autoDiscover = (CheckBox) rootView.findViewById(R.id.checkBox_autoDiscover); autoDiscover.setOnCheckedChangeListener(onCheckedChangeListener); autoCollapseRooms = (CheckBox) rootView.findViewById(R.id.checkBox_autoCollapseRooms); autoCollapseRooms.setOnCheckedChangeListener(onCheckedChangeListener); autoCollapseTimers = (CheckBox) rootView.findViewById(R.id.checkBox_autoCollapseTimers); autoCollapseTimers.setOnCheckedChangeListener(onCheckedChangeListener); showRoomAllOnOffButtons = (CheckBox) rootView.findViewById(R.id.checkBox_showRoomAllOnOffButtons); showRoomAllOnOffButtons.setOnCheckedChangeListener(onCheckedChangeListener); hideAddFAB = (CheckBox) rootView.findViewById(R.id.checkBox_hideAddFAB); hideAddFAB.setOnCheckedChangeListener(onCheckedChangeListener); highlightLastActivatedButton = (CheckBox) rootView.findViewById(R.id.checkBox_highlightLastActivatedButton); highlightLastActivatedButton.setOnCheckedChangeListener(onCheckedChangeListener); vibrateOnButtonPress = (CheckBox) rootView.findViewById(R.id.checkBox_vibrateOnButtonPress); vibrateOnButtonPress.setOnCheckedChangeListener(onCheckedChangeListener); vibrationDurationLayout = (LinearLayout) rootView.findViewById(R.id.linearLayout_vibrationDuration); vibrationDuration = (EditText) rootView.findViewById(R.id.editText_vibrationDuration); vibrationDuration.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void afterTextChanged(Editable s) { if (s != null && s.length() > 0) { SmartphonePreferencesHandler.setVibrationDuration(Integer.valueOf(s.toString())); } } }); keepHistoryDuration = (Spinner) rootView.findViewById(R.id.spinner_keep_history); ArrayAdapter<CharSequence> adapterHistory = ArrayAdapter.createFromResource(getContext(), R.array.keep_history_selection_names, android.R.layout.simple_spinner_item); adapterHistory.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); keepHistoryDuration.setAdapter(adapterHistory); keepHistoryDuration.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { SmartphonePreferencesHandler.setKeepHistoryDuration(position); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); textView_backupPath = (TextView) rootView.findViewById(R.id.textView_backupPath); Button button_changeBackupPath = (Button) rootView.findViewById(R.id.button_changeBackupPath); button_changeBackupPath.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (!PermissionHelper.isWriteExternalStoragePermissionAvailable(getContext())) { Snackbar snackbar = Snackbar.make(rootView, R.string.missing_external_storage_permission, Snackbar.LENGTH_LONG); snackbar.setAction(R.string.grant, new View.OnClickListener() { @Override public void onClick(View v) { ActivityCompat.requestPermissions(MainActivity.getActivity(), new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE }, PermissionConstants.REQUEST_CODE_STORAGE_PERMISSION); } }); snackbar.show(); } PathChooserDialog pathChooserDialog = PathChooserDialog.newInstance(); pathChooserDialog.setTargetFragment(fragment, 0); pathChooserDialog.show(getActivity().getSupportFragmentManager(), null); } }); View.OnClickListener onClickListener = new View.OnClickListener() { @Override public void onClick(View v) { switch (v.getId()) { case R.id.radioButton_darkBlue: SmartphonePreferencesHandler.setTheme(SettingsConstants.THEME_DARK_BLUE); break; case R.id.radioButton_lightBlue: SmartphonePreferencesHandler.setTheme(SettingsConstants.THEME_LIGHT_BLUE); break; case R.id.radioButton_dayNight_blue: SmartphonePreferencesHandler.setTheme(SettingsConstants.THEME_DAY_NIGHT_BLUE); break; default: break; } getActivity().finish(); Intent intent = new Intent(getContext(), MainActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); } }; radioButtonDarkBlue = (RadioButton) rootView.findViewById(R.id.radioButton_darkBlue); radioButtonDarkBlue.setOnClickListener(onClickListener); radioButtonLightBlue = (RadioButton) rootView.findViewById(R.id.radioButton_lightBlue); radioButtonLightBlue.setOnClickListener(onClickListener); radioButtonDayNightBlue = (RadioButton) rootView.findViewById(R.id.radioButton_dayNight_blue); radioButtonDayNightBlue.setOnClickListener(onClickListener); sendLogsProgress = (ProgressBar) rootView.findViewById(R.id.sendLogsProgress); sendLogs = (Button) rootView.findViewById(R.id.button_sendLogs); sendLogs.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { sendLogs.setEnabled(false); sendLogsProgress.setVisibility(View.VISIBLE); new AsyncTask<Void, Void, AsyncTaskResult<Boolean>>() { @Override protected AsyncTaskResult<Boolean> doInBackground(Void... params) { try { LogHandler.sendLogsAsMail(getContext()); return new AsyncTaskResult<>(true); } catch (Exception e) { return new AsyncTaskResult<>(e); } } @Override protected void onPostExecute(AsyncTaskResult<Boolean> booleanAsyncTaskResult) { if (booleanAsyncTaskResult.isSuccess()) { // all is good } else { if (booleanAsyncTaskResult.getException() instanceof MissingPermissionException) { Snackbar snackbar = Snackbar.make(rootView, R.string.missing_external_storage_permission, Snackbar.LENGTH_LONG); snackbar.setAction(R.string.grant, new View.OnClickListener() { @Override public void onClick(View v) { ActivityCompat.requestPermissions(MainActivity.getActivity(), new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE }, PermissionConstants.REQUEST_CODE_STORAGE_PERMISSION); } }); snackbar.show(); } else { StatusMessageHandler.showErrorMessage(getContext(), booleanAsyncTaskResult.getException()); } } sendLogs.setEnabled(true); sendLogsProgress.setVisibility(View.GONE); } }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } }); broadcastReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { Log.d(this, "received intent: " + intent.getAction()); updateUI(); } }; return rootView; }
From source file:com.github.riotopsys.malforandroid2.fragment.MangaDetailFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); readStatus.setAdapter(ArrayAdapter.createFromResource(getActivity(), R.array.manga_status_options, android.R.layout.simple_spinner_dropdown_item)); readStatus.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.manga_status_options, android.R.layout.simple_spinner_dropdown_item)); scoreStatus.setOnItemSelectedListener(this); singleMangaLoader = getLoaderManager().initLoader(0, null, this); singleMangaLoader.forceLoad();/*from w ww.jav a 2s .c o m*/ plusOneChapter.setOnClickListener(this); plusOneVolume.setOnClickListener(this); chapterPannel.setOnClickListener(this); volumePannel.setOnClickListener(this); spinOffs.setOnClickListener(this); alternativeVersions.setOnClickListener(this); animeAdaptations.setOnClickListener(this); addButton.setOnClickListener(this); synopsysContainer.setOnTouchListener(this); }
From source file:com.mbientlab.metawear.app.CustomFragment.java
@Override public void onViewCreated(final View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); ((TextView) view.findViewById(R.id.config_option_title)).setText(R.string.config_name_sensor_fusion_data); fusionModeSelection = (Spinner) view.findViewById(R.id.config_option_spinner); fusionModeSelection.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override//from w w w .j a v a 2 s . co m public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { srcIndex = position; final YAxis leftAxis = chart.getAxisLeft(); if (position == 0) { leftAxis.setAxisMaxValue(1.f); leftAxis.setAxisMinValue(-1.f); } else { leftAxis.setAxisMaxValue(360f); leftAxis.setAxisMinValue(-360f); } refreshChart(false); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); ArrayAdapter<CharSequence> spinnerAdapter = ArrayAdapter.createFromResource(getContext(), R.array.values_fusion_data, android.R.layout.simple_spinner_item); spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); fusionModeSelection.setAdapter(spinnerAdapter); askPermission(); }
From source file:org.storymaker.app.PublishFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { initFragment();//from w w w . ja va2 s . co m // purgePublishTables(); // FIXME for debuging, don't purgePublishTables on load! int layout = getArguments().getInt("layout"); mView = inflater.inflate(layout, null); String storyPathInstancePath = mActivity.getProject().getTemplatePath(); if (storyPathInstancePath != null && !storyPathInstancePath.equals("")) { File f = new File(storyPathInstancePath); String jsonString = JsonHelper.loadJSON(f.getPath(), getActivity().getApplicationContext(), "en"); // FIXME don't hardcode "en" if (jsonString != null) { ArrayList<String> referencedFiles = new ArrayList<String>(); // should not need to insert dependencies to check metadata String language = StoryMakerApp.getCurrentLocale().getLanguage(); mStoryPathInstance = JsonHelper.deserializeStoryPathLibrary(jsonString, f.getAbsolutePath(), referencedFiles, getActivity(), language); } } // mStoryPathInstance = JsonHelper.deserializeStoryPathLibrary(json, storyPathInstancePath, referencedFiles, this, ); if (layout == R.layout.fragment_complete_story) { // FIXME not sure why this check exists ProjectInfoFragment infoFrag = ProjectInfoFragment.newInstance(mActivity.getProject().getId(), false, false); this.getChildFragmentManager().beginTransaction().replace(R.id.fl_info_container, infoFrag).commit(); View view = mView.findViewById(R.id.fl_info_container); view.findViewById(R.id.fl_info_container).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { launchStoryInfoEditMode(); } }); // view.setOnTouchListener(new OnTouchListener() { // // @Override // public boolean onTouch(View v, MotionEvent event) { // // TODO Auto-generated method stub // return true; // } // }) ; ImageView ivThumb = (ImageView) mView.findViewById(R.id.storyThumb); Media[] medias = mActivity.mMPM.mScene.getMediaAsArray(); if (medias.length > 0) { Bitmap bitmap = Media.getThumbnail(mActivity, medias[0], mActivity.mMPM.mProject); if (bitmap != null) { ivThumb.setImageBitmap(bitmap); } } // FIXME figure out what spec we need to try to fetch for preview... could be audio or video mMatchingRenderJob = (new JobTable()).getMatchingFinishedJob(getActivity(), mActivity.mMPM.mProject.getId(), JobTable.TYPE_RENDER, VideoRenderer.SPEC_KEY, mActivity.mMPM.mProject.getUpdatedAt()); if (mMatchingRenderJob != null) { mFileLastExport = new File(mMatchingRenderJob.getResult()); } mProgressText = (TextView) mView.findViewById(R.id.textViewProgress); mProgressText.setText(""); ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(mActivity, R.array.story_sections, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mButtonPlay = (ToggleImageButton) mView.findViewById(R.id.btnPlay); mButtonPlay.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { playClicked(); } }); mButtonUpload = (ToggleImageButton) mView.findViewById(R.id.btnUpload); mButtonUpload.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { uploadClicked(); } }); } return mView; }
From source file:com.yschi.castscreen.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); if (savedInstanceState != null) { mResultCode = savedInstanceState.getInt(STATE_RESULT_CODE); mResultData = savedInstanceState.getParcelable(STATE_RESULT_DATA); }//from w w w.j av a 2 s. c om mContext = this; mMediaProjectionManager = (MediaProjectionManager) getSystemService(Context.MEDIA_PROJECTION_SERVICE); mDiscoverdMap = new HashMap<>(); mDiscoverListView = (ListView) findViewById(R.id.discover_listview); mDiscoverAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1); mDiscoverAdapter.addAll(mDiscoverdMap.keySet()); mDiscoverListView.setAdapter(mDiscoverAdapter); mDiscoverListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { String name = mDiscoverAdapter.getItem(i); String ip = mDiscoverdMap.get(name); Log.d(TAG, "Select receiver name: " + name + ", ip: " + ip); mReceiverIp = ip; updateReceiverStatus(); mContext.getSharedPreferences(PREF_COMMON, 0).edit().putString(PREF_KEY_RECEIVER, mReceiverIp) .commit(); } }); // add server mode option mDiscoverAdapter.add(mContext.getString(R.string.server_mode)); mDiscoverdMap.put(mContext.getString(R.string.server_mode), ""); mReceiverTextView = (TextView) findViewById(R.id.receiver_textview); final EditText ipEditText = (EditText) findViewById(R.id.ip_edittext); final Button selectButton = (Button) findViewById(R.id.select_button); selectButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (ipEditText.getText().length() > 0) { mReceiverIp = ipEditText.getText().toString(); Log.d(TAG, "Using ip: " + mReceiverIp); updateReceiverStatus(); mContext.getSharedPreferences(PREF_COMMON, 0).edit() .putString(PREF_KEY_INPUT_RECEIVER, mReceiverIp).commit(); mContext.getSharedPreferences(PREF_COMMON, 0).edit().putString(PREF_KEY_RECEIVER, mReceiverIp) .commit(); } } }); ipEditText.setText(mContext.getSharedPreferences(PREF_COMMON, 0).getString(PREF_KEY_INPUT_RECEIVER, "")); Spinner formatSpinner = (Spinner) findViewById(R.id.format_spinner); ArrayAdapter<CharSequence> formatAdapter = ArrayAdapter.createFromResource(this, R.array.format_options, android.R.layout.simple_spinner_item); formatAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); formatSpinner.setAdapter(formatAdapter); formatSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { mSelectedFormat = FORMAT_OPTIONS[i]; mContext.getSharedPreferences(PREF_COMMON, 0).edit().putInt(PREF_KEY_FORMAT, i).commit(); } @Override public void onNothingSelected(AdapterView<?> adapterView) { mSelectedFormat = FORMAT_OPTIONS[0]; mContext.getSharedPreferences(PREF_COMMON, 0).edit().putInt(PREF_KEY_FORMAT, 0).commit(); } }); formatSpinner.setSelection(mContext.getSharedPreferences(PREF_COMMON, 0).getInt(PREF_KEY_FORMAT, 0)); Spinner resolutionSpinner = (Spinner) findViewById(R.id.resolution_spinner); ArrayAdapter<CharSequence> resolutionAdapter = ArrayAdapter.createFromResource(this, R.array.resolution_options, android.R.layout.simple_spinner_item); resolutionAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); resolutionSpinner.setAdapter(resolutionAdapter); resolutionSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { mSelectedWidth = RESOLUTION_OPTIONS[i][0]; mSelectedHeight = RESOLUTION_OPTIONS[i][1]; mSelectedDpi = RESOLUTION_OPTIONS[i][2]; mContext.getSharedPreferences(PREF_COMMON, 0).edit().putInt(PREF_KEY_RESOLUTION, i).commit(); } @Override public void onNothingSelected(AdapterView<?> adapterView) { mSelectedWidth = RESOLUTION_OPTIONS[0][0]; mSelectedHeight = RESOLUTION_OPTIONS[0][1]; mSelectedDpi = RESOLUTION_OPTIONS[0][2]; mContext.getSharedPreferences(PREF_COMMON, 0).edit().putInt(PREF_KEY_RESOLUTION, 0).commit(); } }); resolutionSpinner .setSelection(mContext.getSharedPreferences(PREF_COMMON, 0).getInt(PREF_KEY_RESOLUTION, 0)); Spinner bitrateSpinner = (Spinner) findViewById(R.id.bitrate_spinner); ArrayAdapter<CharSequence> bitrateAdapter = ArrayAdapter.createFromResource(this, R.array.bitrate_options, android.R.layout.simple_spinner_item); bitrateAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); bitrateSpinner.setAdapter(bitrateAdapter); bitrateSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { mSelectedBitrate = BITRATE_OPTIONS[i]; mContext.getSharedPreferences(PREF_COMMON, 0).edit().putInt(PREF_KEY_BITRATE, i).commit(); } @Override public void onNothingSelected(AdapterView<?> adapterView) { mSelectedBitrate = BITRATE_OPTIONS[0]; mContext.getSharedPreferences(PREF_COMMON, 0).edit().putInt(PREF_KEY_BITRATE, 0).commit(); } }); bitrateSpinner.setSelection(mContext.getSharedPreferences(PREF_COMMON, 0).getInt(PREF_KEY_BITRATE, 0)); mReceiverIp = mContext.getSharedPreferences(PREF_COMMON, 0).getString(PREF_KEY_RECEIVER, ""); updateReceiverStatus(); startService(); }