List of usage examples for android.widget TextView getText
@ViewDebug.CapturedViewProperty
public CharSequence getText()
From source file:moe.minori.androidoauthtutorialproject.MainActivity.java
@Override protected void onResume() { super.onResume(); // Fill hardcoded constants to UI on first UI inflation if (!isInFlatedUI) { TextView authUrlTextView = (TextView) findViewById(R.id.authUrlTextView); authUrlTextView.setText(authUrlTextView.getText() + Constants.authURL); TextView accessEndpointTextView = (TextView) findViewById(R.id.accessEndpointTextView); accessEndpointTextView.setText(accessEndpointTextView.getText() + Constants.accessEndpointURL); isInFlatedUI = true;//from w w w . j av a2 s . c o m } // Fill non-hardcoded variables to UI on UI resume TextView accessTokenTextView = (TextView) findViewById(R.id.accessTokenTextView); if (accessToken != null) accessTokenTextView.setText(getString(R.string.accessTokenTextViewString) + accessToken); TextView refreshTokenTextView = (TextView) findViewById(R.id.refreshTokenTextView); if (refreshToken != null) refreshTokenTextView.setText(getString(R.string.refreshTokenTextViewString) + refreshToken); TextView expiresInTextView = (TextView) findViewById(R.id.tokenExpiryTextView); expiresInTextView.setText(getString(R.string.tokenExpiryTextViewString) + expires_in); EditText accessResultEditText = (EditText) findViewById(R.id.accessResultEditText); if (accessResult != null) accessResultEditText.setText(accessResult); }
From source file:com.aqnote.app.wifianalyzer.about.AboutActivityTest.java
@Test public void testVersionNumber() throws Exception { // setup//from w w w. j a v a 2 s.c o m String packageName = fixture.getPackageName(); PackageInfo packageInfo = fixture.getPackageManager().getPackageInfo(packageName, 0); String expected = packageInfo.versionName; if (isDevelopmentMode) { expected += " - " + packageInfo.versionCode + " SDK:" + Build.VERSION.SDK_INT; } // execute TextView actual = (TextView) fixture.findViewById(R.id.about_version_info); // validate assertNotNull(actual); assertEquals(expected, actual.getText()); }
From source file:com.ibm.mil.readyapps.summit.fragments.CreateListFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View layout = inflater.inflate(R.layout.fragment_create_list, container, false); getActivity().setTitle(getString(R.string.create_list_title)); // submit list name when user clicks 'Done' key on soft keyboard mEnterListName = (EditText) layout.findViewById(R.id.enter_list_name); mEnterListName.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override/*from w ww. jav a 2 s. com*/ public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_DONE) { createList(v.getText().toString()); return true; } return false; } }); // configure UI depending on display mode if (isOverlayMode()) { TextView createNewList = (TextView) layout.findViewById(R.id.create_new_list); createNewList.setTypeface(FontCache.getFont(getActivity(), FontCache.FontName.OSWALD_REGULAR)); ImageButton backButton = (ImageButton) layout.findViewById(R.id.back_button); backButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { getFragmentManager().popBackStackImmediate(); } }); mEnterListName.setHint(getString(R.string.list_name_hint)); } else { View overlayHeader = layout.findViewById(R.id.overlay_header); overlayHeader.setVisibility(View.GONE); } return layout; }
From source file:com.enadein.carlogbook.ui.AboutFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); TextView linkSrc = (TextView) view.findViewById(R.id.link_src); linkSrc.setOnClickListener(new View.OnClickListener() { @Override// w w w . j av a 2s . c o m public void onClick(View view) { openUrl(getString(R.string.open_src_url)); } }); view.findViewById(R.id.lib1).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { openUrl(getString(R.string.lib1_val_url)); } }); view.findViewById(R.id.link_ask).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { sendEmail(getString(R.string.email_subject_ask)); } }); view.findViewById(R.id.link_provide).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { sendEmail(getString(R.string.email_subject_provide)); } }); view.findViewById(R.id.lic).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { getMediator().showLic(); } }); view.findViewById(R.id.link_rate).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { rateApp(); } }); view.findViewById(R.id.don1).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { donate(CarLogbook.PRODUCT_1, AboutFragment.this); } }); view.findViewById(R.id.don2).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { donate(CarLogbook.PRODUCT_2, AboutFragment.this); } }); view.findViewById(R.id.don3).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { donate(CarLogbook.PRODUCT_3, AboutFragment.this); } }); TextView versionView = (TextView) view.findViewById(R.id.ver); versionView.setText(versionView.getText() + ": " + CarLogbook.VERSION); }
From source file:cl.ipp.katbag.fragment.Board.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { v = inflater.inflate(R.layout.fragment_board, container, false); mainActivity = (MainActivity) super.getActivity(); notRegister = (TextView) v.findViewById(R.id.board_not_register); boardListView = (DragSortListView) v.findViewById(R.id.board_list_view); boardListView.setOnItemClickListener(new OnItemClickListener() { @Override/*from w ww . ja va2 s . c om*/ public void onItemClick(AdapterView<?> parent, View view, int position, long id) { TextView idApp = (TextView) view.findViewById(R.id.board_row_id); TextView typeApp = (TextView) view.findViewById(R.id.board_row_type); TextView nameApp = (TextView) view.findViewById(R.id.board_row_name); if (typeApp.getText().toString().contentEquals(MainActivity.TYPE_APP_GAME)) mFragment = new Player(); else mFragment = new PlayerBook(); Bundle bundle = new Bundle(); bundle.putLong("id_app", Long.parseLong(idApp.getText().toString())); bundle.putString("name_app", nameApp.getText().toString()); bundle.putString("type_app", typeApp.getText().toString()); bundle.putBoolean("editMode", false); mFragment.setArguments(bundle); FragmentTransaction t = getActivity().getSupportFragmentManager().beginTransaction(); t.replace(R.id.fragment_main_container, mFragment); t.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE); t.addToBackStack(mFragment.getClass().getSimpleName()); t.commit(); } }); return v; }
From source file:com.google.firebase.quickstart.fcm.MainActivity.java
private void logDataTextView(String title) { final TextView dataTextView = (TextView) findViewById(R.id.dataTextView); Log.d(TAG, String.format("%s:\n%s", title, (String) dataTextView.getText())); }
From source file:can.yrt.onebusaway.MySearchStopsFragment.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo; final TextView text = (TextView) info.targetView.findViewById(R.id.stop_name); menu.setHeaderTitle(text.getText()); if (isShortcutMode()) { menu.add(0, CONTEXT_MENU_DEFAULT, 0, R.string.my_context_create_shortcut); } else {// ww w. ja va 2 s.c o m menu.add(0, CONTEXT_MENU_DEFAULT, 0, R.string.my_context_get_stop_info); } menu.add(0, CONTEXT_MENU_SHOW_ON_MAP, 0, R.string.my_context_showonmap); }
From source file:com.google.firebase.quickstart.fcm.MainActivity.java
private void updateDataTextView(Intent intent) { logDataTextView("BEFORE UPDATE"); restoreDataTextView();//from w w w .j av a 2s.c o m if (intent != null && intent.getExtras() != null) { Bundle extras = intent.getExtras(); String msg = ""; for (String key : extras.keySet()) { Object value = extras.get(key); if (key.equalsIgnoreCase("google.sent_time") || key.equalsIgnoreCase("from") || key.equalsIgnoreCase("google.message_id") || key.equalsIgnoreCase("collapse_key")) { Log.d(TAG, String.format("Ignored key: %s Value: %s", key, value)); } else { if (msg.isEmpty()) { msg = String.format("Key: %s Value: %s", key, value); } else { msg = String.format("%s\nKey: %s Value: %s", msg, key, value); } } } Log.d(TAG, String.format("Generated message:\n%s", msg)); TextView dataTextView = (TextView) findViewById(R.id.dataTextView); String currentText = (String) dataTextView.getText(); if (currentText.contains("Notification message should be displayed here...")) { dataTextView.setText(msg); } else { dataTextView.setText(String.format("%s\n%s", currentText, msg)); } } saveDataTextView(); logDataTextView("AFTER UPDATE"); }
From source file:com.csipsimple.utils.contacts.ContacksSearchGridAdapter.java
private boolean highlightTextViewSearch(TextView tv) { if (currentFilter.length() > 0) { String value = tv.getText().toString(); int foundIdx = value.toLowerCase().indexOf(currentFilter); if (foundIdx >= 0) { SpannableString spn = new SpannableString(value); spn.setSpan(boldStyle, foundIdx, foundIdx + currentFilter.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); spn.setSpan(highlightStyle, foundIdx, foundIdx + currentFilter.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); tv.setText(spn);// ww w .j ava 2s .c o m return true; } } return false; }
From source file:com.fullmeadalchemist.mustwatch.ui.batch.form.AddIngredientDialog.java
@NonNull @Override/*from ww w .j a v a 2s.c o m*/ public Dialog onCreateDialog(Bundle savedInstanceState) { View view = LayoutInflater.from(getActivity()).inflate(R.layout.ingredient_dialog, null); viewModel = ViewModelProviders.of(this, viewModelFactory).get(BatchFormViewModel.class); String typeString = getArguments().getString(INGREDIENT_TYPE); Ingredient.IngredientType type; type = Ingredient.IngredientType.fromString(typeString); if (type == null) { type = Ingredient.IngredientType.SUGAR; } Timber.d("Got INGREDIENT_TYPE=%s", type); spinnerItems = new ArrayList<>(); LiveData<List<Ingredient>> ingredientsSpinnerObjects; int unitsSpinnerResource = 0; switch (type) { case YEAST: unitsSpinnerResource = R.array.mass_units_list; ingredientsSpinnerObjects = viewModel.getYeasts(); break; case NUTRIENT: unitsSpinnerResource = R.array.mass_units_list; ingredientsSpinnerObjects = viewModel.getNutrients(); break; case STABILIZER: unitsSpinnerResource = R.array.mass_units_list; ingredientsSpinnerObjects = viewModel.getStabilizers(); break; case SUGAR: default: unitsSpinnerResource = R.array.sugar_units_list; ingredientsSpinnerObjects = viewModel.getSugars(); break; } ingredientsSpinnerObjects.observe(this, ingredients -> { if (ingredients != null) { Timber.d("updating ingredients spinner with %d objects", ingredients.size()); spinnerItems = ingredients; List<String> stringifiedIngredients = new ArrayList<>(ingredients.size()); for (Ingredient ingredient : ingredients) { if (ingredient != null) { int resID = getResources().getIdentifier(ingredient.id, "string", this.getActivity().getPackageName()); stringifiedIngredients.add(getString(resID)); } else { Timber.e("Got a null ingredient from the database!?"); } } Spinner ingredientsSpinner = view.findViewById(R.id.ingredients_spinner); ArrayAdapter<String> ingredientsAdapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_spinner_item, stringifiedIngredients); ingredientsAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); ingredientsSpinner.setAdapter(ingredientsAdapter); } }); Spinner unitsSpinner = view.findViewById(R.id.quantity_unit_spinner); ArrayAdapter<CharSequence> unitsAdapter = ArrayAdapter.createFromResource(getActivity(), unitsSpinnerResource, android.R.layout.simple_spinner_item); unitsAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); unitsSpinner.setAdapter(unitsAdapter); return new AlertDialog.Builder(getActivity()).setView(view) .setPositiveButton(android.R.string.ok, (dialog, which) -> { Spinner spinner = view.findViewById(R.id.ingredients_spinner); int selectedItemId = safeLongToInt(spinner.getSelectedItemId()); Ingredient selectedIngredient = spinnerItems.get(selectedItemId); Timber.d("Registered spinner number %d selected, corresponding to ingredient %s", selectedItemId, selectedIngredient.id); TextView qtyAmount = view.findViewById(R.id.quantity_amount); String qtyAmountValueText = qtyAmount.getText().toString(); float qtyValue = toFloat(qtyAmountValueText, 0.0f); //Spinner unitsSpinner = view.findViewById(R.id.quantity_unit_spinner); String selectedUnit = unitsSpinner.getSelectedItem().toString(); Timber.d("Ingredient selected: %s, %s %s", selectedIngredient.id, qtyValue, selectedUnit); Intent intent = new Intent(INGREDIENT_SET_EVENT); intent.putExtra(INGREDIENT, selectedIngredient.id); intent.putExtra(AMOUNT, qtyValue); intent.putExtra(UNIT, selectedUnit); LocalBroadcastManager.getInstance(getActivity()).sendBroadcast(intent); }).setNegativeButton(android.R.string.cancel, null).create(); }