Best code examples for TextView getText method (android.widget.TextView.getText)

These code examples were ranked by Codota’s semantic indexing as the best open source examples for TextView getText method.
You can now enable Codota on your own code to easily search and navigate your Java codebase.

TextView getText examples from Open Source projects
This code example shows how to use the following methods: getText, setText
29:	TextView textView = new TextView(context); 
30:	textView.setText(Html.fromHtml("<b>some</b> html text")); 
31:	assertThat(textView.getText().toString()).isEqualTo("<b>some</b> html text"); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: getLinksClickable, getText, setMovementMethod, setText
34:	CharSequence content = view.getText(); 
35:	view.setText(convertNormalStringToSpannableString(content.toString())); 
36:	if (view.getLinksClickable()) { 
37:	view.setMovementMethod(LongClickableLinkMovementMethod.getInstance()); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: getText, setText, getWindowToken
74:	adapter.add(v.getText().toString()); 
75:	v.setText(""); 
-
80:	imm.hideSoftInputFromWindow(v.getWindowToken(), 0); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: getText, setLinkTextColor, addLinks
45:	if(!TextUtils.isEmpty(notesPreview.getText())) { 
46:	notesPreview.setLinkTextColor(Color.rgb(100, 160, 255)); 
47:	Linkify.addLinks(notesPreview, Linkify.ALL); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: getText, setText
50:	transcript.setText(transcript.getText().toString()+"Shaking started\n"); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getText, getVisibility
100:	CharSequence text = realTextView.getText(); 
101:	return (text == null || realTextView.getVisibility() != View.VISIBLE) ? "" : text.toString(); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getText, getTextColors, getTextSize
64:	if (tv.getText().toString().startsWith(TEXT_SEARCH_PREFIX)) { 
65:	int textColour = tv.getTextColors().getDefaultColor(); 
66:	TextAppearance appearance = new TextAppearance(textColour, tv.getTextSize()/displayMetrics.scaledDensity); 
-
68:	if (TEXT_SEARCH_TEXT.equals(tv.getText().toString())) { 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: getText, length, setText, setTextColor, setTextSize
182:	TextView tv = new TextView(this); 
-
187:	tv.setLayoutParams(lp); 
-
189:	tv.setText(info.activityInfo.loadLabel(getPackageManager())); 
190:	tv.setTextColor(Color.BLACK); 
191:	tv.setTextSize(15); 
-
194:	tv.setText(tv.getText(), TextView.BufferType.SPANNABLE); 
195:	Spannable str = (Spannable) tv.getText(); 
-
200:	0, tv.length(), 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getMovementMethod, getText, setMovementMethod, setText
32:	CharSequence text = view.getText(); 
-
46:	view.setText(s); 
-
49:	MovementMethod m = view.getMovementMethod(); 
-
51:	view.setMovementMethod(LinkMovementMethod.getInstance()); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getText, setText
161:	mLog.setText(mLog.getText() + "\n" + mDateFormat.format(new Date()) + ": " + s); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getText
98:	CharSequence actual = text.getText(); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getText, setPadding, setTextColor, setTextSize
111:	final String option = tv.getText().toString(); 
-
119:	tv.setTextSize(24.0f); 
-
124:	tv.setTextColor(Color.BLACK); 
125:	tv.setPadding(10, 3, 3, 3); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getText, getVisibility
75:	assertEquals(View.VISIBLE, textView.getVisibility()); 
76:	assertEquals(expectedText, textView.getText().toString()); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getText
53:	data.put("text", b.getText().toString()); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getText
68:	return te.getText().toString(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getText, getId
25:	Timber.i("A button with ID %s was clicked to say '%s'.", button.getId(), button.getText()); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getText, setText
52:	String string = button.getText().toString(); 
-
54:	button.setText(String.valueOf(hitTarget)); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getText
40:	Validate field2Validator = new Validate(_field2); 
-
43:	if(field1Validator.isValid(_field1.getText().toString()) || field2Validator.isValid(_field2.getText().toString())){ 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getText
231:	return mTitle.getText(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getText, setContentDescription
22:	myView.setContentDescription(myView.getText()); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getText
27:	if(_field1.getText().toString().length() > 0 && _field1.getText().toString().equals(_field2.getText().toString())){ 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getText
231:	return mTitle.getText(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getText, isChecked
41:	if(radioMale.isChecked()) { 
42:	resultIntent.putExtra("dlr.stressrecognition.Gender", radioMale.getText()); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getText, setText
57:	return mUsernameView.getText().toString(); 
-
98:	mUsernameView.setText(username); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getText
63:	String text = (String) buttonView.getText(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getText
138:	setDeviceName(v.getText().toString()); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getText, setEnabled, setText
92:	final CharSequence currentText = moveonButton.getText(); 
93:	moveonButton.setText("Move on skickat!"); 
94:	moveonButton.setEnabled(false); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getText, setText
91:	String text = v.getText().toString(); 
-
93:	v.setText(""); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getText
34:	assertEquals("42", textView.getText().toString()); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getText
120:	return this.date.getText().toString(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getText, isChecked, setChecked
46:	if (textView.isChecked()){ 
-
48:	textView.getText().toString(), false); 
-
52:	textView.getText().toString(), true); 
-
59:	textView.setChecked(!textView.isChecked()); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getText
61:	.putExtra(prefix + ".PORT", mServerPort.getText().toString()) 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getText, setText
79:	if(btn.getText().toString().trim().equals("Start Data Pull")){ 
-
85:	}else if(btn.getText().toString().trim().equals("Stop Data Pull")){ //if the text says 'stop data pull' then stop the AsyncTask 
-
89:	btn.setText("Start Data Pull"); 
90:	}else if(btn.getText().toString().trim().equals("Clear")){ //If the text says 'clear' then clear the textview that holds the results 
-
92:	btn.setText("Start Data Pull"); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: getText, getId, isChecked
39:	Log.d(TAG, "" + toggle.getId()); 
40:	Log.d(TAG, "" + toggle.getText()); 
41:	Log.d(TAG, "" + toggle.isChecked()); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: getText
37:	Toast.makeText(this, view.getText(), Toast.LENGTH_SHORT).show(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getText, setText
46:	String label = btn.getText().toString(); 
-
51:	btn.setText(label); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: getText
68:	item.mTextView.setText(mTextView.getText()); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getText
204:	return this.category.getText().toString(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getText
49:	return textView.getText().toString(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getText, setBase, start
22:	String chronoText = mChronometer.getText().toString(); 
-
32:	mChronometer.setBase(SystemClock.elapsedRealtime() - stoppedMilliseconds); 
33:	mChronometer.start(); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: getText, setBase, setVisibility, start
353:	timer.setBase(chronoBaseTime); 
-
356:	timer.start(); 
357:	timer.setVisibility(chronoVisibility); 
358:	System.out.println("Timer - " + timer.getText()); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: getText, isChecked, toggle
64:	String s = (String) ctv.getText(); 
65:	ctv.toggle(); 
66:	if (ctv.isChecked()) 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: getText, getContext
14:	String text = arg0.getText().toString(); 
-
21:	ArrayList<ItemLoc> itemList = utils.readGroceryListFile(arg0.getContext()); 
-
23:	utils.saveFile(itemList, arg0.getContext()); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: getText, getContext
52:	String text = arg0.getText().toString(); 
-
59:	ArrayList<ItemLoc> list = utils.readKnownItemsListFile(arg0.getContext()); 
-
61:	utils.saveFile(list, arg0.getContext()); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: getText
109:	outState.putCharSequence("startstop", mStartButton.getText()); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: getText, setBase, start
295:	String chronoText = timeWaitingChronometer.getText().toString(); 
-
305:	timeWaitingChronometer.setBase(SystemClock.elapsedRealtime() - stoppedMilliSec); 
-
311:	timeWaitingChronometer.start(); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: getText, isChecked
48:	} else if (beta.isChecked()) { 
49:	tv.setText(beta.getText()); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: getText, getId
42:	if(checkedId==mRadio1.getId()) 
-
45:	mTextView1.setText(mRadio1.getText()); 
Full Snippet Info
5
CodeRank
Related TextView getText Questions & Answers:
Other TextView getText Examples
49:	
50:	  public void onClick(View view) {
51:	    String string = button.getText().toString();
52:	    int hitTarget = Integer.valueOf(string) + 1;
53:	    button.setText(String.valueOf(hitTarget));

Read More

57:				@Override
58:				public void onClick(View v) {
59:					if (txtCategory.getText().toString().trim().length() > 0) {
60:						
61:						// new category name
-
60:						
61:						// new category name
62:						String newCategory = txtCategory.getText().toString();
63:	
64:						// Call Async task to create new category

Read More

32:				@Override
33:				public void onClick(View v) {
34:					if (txtCategory.getText().toString().trim().length() > 0) {
35:						
36:						// new category name
-
35:						
36:						// new category name
37:						String newCategory = txtCategory.getText().toString();
38:	
39:						// Call Async task to create new category

Read More

Displays text to the user and optionally allows them to edit it. A TextView is a complete text editor, however the basic class is configured to not allow editing; see EditText for a subclass that configures the text view for editing.

To allow users to copy some or all of the TextView's value and paste it somewhere else, set the XML attribute android:textIsSelectable to "true" or call setTextIsSelectable(true). The textIsSelectable flag allows users to make selection gestures in the TextView, which in turn triggers the system's built-in copy/paste controls....
getText Method Overview
Return the text the TextView is displaying.
See Also
  • addTextChangedListener
    Adds a TextWatcher to the list of those whose methods are called whenever this TextView's text changes.
  • append
    Convenience method: Append the specified text to the TextView's display buffer, upgrading it to BufferType.EDITABLE if it was not already editable.
  • extractText
    If this TextView contains editable content, extract a portion of it based on the information in request in to outText.
  • getError
    Returns the error message that was set to be displayed with setError(CharSequence), or null if no error was set or if it the error was cleared by the widget after user input.
  • getGravity
    Returns the horizontal and vertical alignment of this TextView.
  • getLinksClickable
    Returns whether the movement method will automatically be set to LinkMovementMethod if setAutoLinkMask(int) has been set to nonzero and links are detected in setText(char[], int, int).
  • getTextColors
    Gets the text colors for the different states (normal, selected, focused) of the TextView.
  • length
    Returns the length, in characters, of the text managed by this TextView
  • onCommitCompletion
    Called by the framework in response to a text completion from the current input method, provided by it calling InputConnection.commitCompletion().
  • onCommitCorrection
    Called by the framework in response to a text auto-correction (such as fixing a typo using a a dictionnary) from the current input method, provided by it calling commitCorrection(CorrectionInfo) InputConnection.commitCorrection()}.
  • onTouchEvent
    Implement this method to handle touch screen motion events.
  • removeTextChangedListener
    Removes the specified TextWatcher from the list of those whose methods are called whenever this TextView's text changes.
  • setCompoundDrawables
    Sets the Drawables (if any) to appear to the left of, above, to the right of, and below the text.
  • setEllipsize
    Causes words in the text that are longer than the view is wide to be ellipsized instead of broken in the middle.
  • setError
    Sets the right-hand compound drawable of the TextView to the "error" icon and sets an error message that will be displayed in a popup when the TextView has focus.
  • setFilters
    Sets the list of input filters that will be used if the buffer is Editable.
  • setGravity
    Sets the horizontal alignment of the text and the vertical gravity that will be used when there is extra space in the TextView beyond what is required for the text itself.
  • setHeight
    Makes the TextView exactly this many pixels tall.
  • setHint
    Sets the text to be displayed when the text of the TextView is empty.
  • setImeOptions
    Change the editor type integer associated with the text view, which will be reported to an IME with imeOptions when it has focus.
  • setInputType
    Set the type of the content with a constant as defined for inputType.
  • setLines
    Makes the TextView exactly this many lines tall.
  • setMaxHeight
    Makes the TextView at most this many pixels tall.
  • setMaxLines
    Makes the TextView at most this many lines tall.
  • setMaxWidth
    Makes the TextView at most this many pixels wide
  • setMinLines
    Makes the TextView at least this many lines tall.
  • setMinWidth
    Makes the TextView at least this many pixels wide
  • setMovementMethod
    Sets the movement method (arrow key handler) to be used for this TextView.
  • setPaintFlags
    Sets flags on the Paint being used to display the text and reflows the text if they are different from the old flags.
  • setRawInputType
    Directly change the content type integer of the text view, without modifying any other state.
  • setShadowLayer
    Gives the text a shadow of the specified radius and color, the specified distance from its normal position.
  • setSingleLine
    Sets the properties of this field (lines, horizontally scrolling, transformation method) to be for a single-line input.
  • setTextAppearance
    Sets the text color, size, style, hint color, and highlight color from the specified TextAppearance resource.
  • setTextSize
    Set the default text size to the given value, interpreted as "scaled pixel" units.
  • setTypeface
    Sets the typeface and style in which the text should be displayed, and turns on the fake bold and italic bits in the Paint if the Typeface that you provided does not have all the bits in the style that you specified.
  • setWidth
    Makes the TextView exactly this many pixels wide.