Android TextView - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android TextView class.

This code example shows how to use the following methods: setFocusable, setFocusableInTouchMode, setLayoutParams, setOnKeyListener, getImeOptions
This code example shows how to use the following methods: setPadding, setText, setTextColor, setTextSize
     
    TextView textView = (TextView)row.findViewById(android.R.id.text1);
    float scale = activity.getResources().getDisplayMetrics().density;
    boolean leftPadding = (parent.getTag().equals("right"));
    boolean topPadding = (position == 0);
    textView.setPadding((int)(20 * scale) * (leftPadding ? 2 : 1), (int)(20 * scale) * (!leftPadding && topPadding ? 1 : 0), (int)(20 * scale), 0);
    textView.setText(item);
    textView.setTextColor(Color.BLACK);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16);
     
    return row;
  } 
 
  private View getWebView(int position, View convertView, ViewGroup parent) {
    View row = convertView;
    if ((row == null) || (row.findViewById(1337) == null)) {
      RelativeLayout layout = new RelativeLayout(activity);
      layout.setLayoutParams(new ListView.LayoutParams(ListView.LayoutParams.FILL_PARENT, ListView.LayoutParams.WRAP_CONTENT));
      row = layout;
       
Full Snippet Info
9
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods: getScrollX, getScrollY, getLayout, getTotalPaddingLeft, getTotalPaddingTop
 
		if (action == MotionEvent.ACTION_UP) {
			int x = (int) event.getX();
			int y = (int) event.getY();
 
			x -= widget.getTotalPaddingLeft();
			y -= widget.getTotalPaddingTop();
 
			x += widget.getScrollX();
			y += widget.getScrollY();
 
			Layout layout = widget.getLayout();
			int line = layout.getLineForVertical(y);
			int off = layout.getOffsetForHorizontal(line, x);
 
			ClickableSpan[] links = buffer.getSpans(off, off,
					ClickableSpan.class);
 
			if (links.length != 0 && links[0] instanceof URLSpan) {
				HashMap args = new HashMap();
Full Snippet Info
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods: getVisibility, setVisibility, setText
        mPreserveIconSpacing = mForceShowIcon = forceShow;
    } 
 
    public void setTitle(CharSequence title) {
        if (title != null) {
            mTitleView.setText(title);
 
            if (mTitleView.getVisibility() != VISIBLE) mTitleView.setVisibility(VISIBLE);
        } else { 
            if (mTitleView.getVisibility() != GONE) mTitleView.setVisibility(GONE);
        } 
    } 
 
    public MenuItemImpl getItemData() { 
        return mItemData;
    } 
 
    public void setCheckable(boolean checkable) {
 
        if (!checkable && mRadioButton == null && mCheckBox == null) {
Full Snippet Info
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods: setLayoutParams, setGravity, setText
         * number. 
         */ 
        @Override 
        public View onCreateView(LayoutInflater inflater, ViewGroup container,
                Bundle savedInstanceState) {
            TextView tv = new TextView(getActivity());
            tv.setLayoutParams(new ViewGroup.LayoutParams(MATCH_PARENT,
                    MATCH_PARENT));
            tv.setText("Fragment #" + mNum);
            tv.setGravity(CENTER);
            return tv;
        } 
 
    } 
} 
Full Snippet Info
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods: setText
     
    return(btn);
  } 
   
  private View buildFooter() {
    TextView txt=new TextView(this);
     
    updateFooter(txt);
     
    return(txt);
  } 
   
  private void updateFooter(final TextView txt) {
    long runtime=(SystemClock.uptimeMillis()-startTime)/1000;
     
    txt.setText(String.valueOf(runtime)+" seconds since activity launched");
     
    if (!areWeDeadYet) {
      getListView().postDelayed(new Runnable() {
        public void run() { 

8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods: setId, setVisibility, setGravity, setPadding, setText
This code example shows how to use the following methods: setTag, setVisibility, setText
    private HttpImageGetter show(final TextView view, final CharSequence html) {
        if (TextUtils.isEmpty(html))
            return hide(view);
 
        try { 
            view.setText(html);
        } 
        catch (Exception e) {
        } 
        view.setVisibility(VISIBLE);
        view.setTag(null);
        return this;
    } 
 
    private HttpImageGetter hide(final TextView view) {
        view.setText(null);
        view.setVisibility(GONE);
        view.setTag(null);
        return this;
    } 

8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods: setGravity, setPadding, setText, setTextSize
		playerText.setText(score.getPlayer());
		playerText.setGravity(Gravity.LEFT);
		playerText.setPadding(10, 10, 10, 10);
		playerText.setTextSize(16);
 
		TextView scoreText = new TextView(parent.getContext());
		scoreText.setText(String.valueOf(score.getScore()));
		scoreText.setGravity(Gravity.RIGHT);
		scoreText.setPadding(10, 10, 10, 10);
		scoreText.setTextSize(16);
 
		layout.addView(playerText);
		layout.addView(scoreText);
 
		return layout;
	} 
 
	public List<HighScore> getScores() {
		return scores;
	} 
Full Snippet Info
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods: setLayoutParams, setGravity, setText
         * instance number. 
         */ 
        @Override 
        public View onCreateView(LayoutInflater inflater, ViewGroup container,
                                 Bundle savedInstanceState) {
            TextView tv = new TextView(getActivity());
            tv.setLayoutParams(new ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT));
            tv.setText("Fragment #" + mNum);
            tv.setGravity(CENTER);
            return tv;
        } 
 
    } 
} 
 
Full Snippet Info
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java

Related Android TextView Questions & Answers:

Other Android TextView Examples

10:	        super.onCreate(savedInstanceState);
11:	        setContentView(R.layout.activity_main);
12:	        TextView view =  (TextView) findViewById(R.id.TextView02);
13:	        String s="";
14:	        for (int i=0; i < 500; i++) {
-
10:	        super.onCreate(savedInstanceState);
11:	        setContentView(R.layout.activity_main);
12:	        TextView view =  (TextView) findViewById(R.id.TextView02);
13:	        String s="";
14:	        for (int i=0; i < 500; i++) {

Read More

11:	
12:	public class ShowLocationActivity extends Activity implements LocationListener {
13:	  private TextView latituteField;
14:	  private TextView longitudeField;
15:	  private LocationManager locationManager;
-
12:	public class ShowLocationActivity extends Activity implements LocationListener {
13:	  private TextView latituteField;
14:	  private TextView longitudeField;
15:	  private LocationManager locationManager;
16:	  private String provider;
-
21:	    super.onCreate(savedInstanceState);
22:	    setContentView(R.layout.main);
23:	    latituteField = (TextView) findViewById(R.id.TextView02);
24:	    longitudeField = (TextView) findViewById(R.id.TextView04);
25:	
-
22:	    setContentView(R.layout.main);
23:	    latituteField = (TextView) findViewById(R.id.TextView02);
24:	    longitudeField = (TextView) findViewById(R.id.TextView04);
25:	
26:	    // Get the location manager

Read More

1:	
2:		TextView txtMessage;
3:	
4:		// Animation
-
10:			setContentView(R.layout.activity_fadein);
11:	
12:			txtMessage = (TextView) findViewById(R.id.txtMessage);
13:	
14:			// load the animation

Read More

11:	        this.setContentView(R.layout.single_list_item_view);
12:	        
13:	        TextView txtProduct = (TextView) findViewById(R.id.product_label);
14:	        
15:	        Intent i = getIntent();
-
11:	        this.setContentView(R.layout.single_list_item_view);
12:	        
13:	        TextView txtProduct = (TextView) findViewById(R.id.product_label);
14:	        
15:	        Intent i = getIntent();

Read More

0:	TextView txtView1, txtView2;
1:	Animation animFadeIn, animFadeOut;
2:	.

Read More

3:	
4:	    private MyFirstTestActivity mFirstTestActivity;
5:	    private TextView mFirstTestText;
6:	
7:	    public MyFirstTestActivityTest() {
-
14:	        mFirstTestActivity = getActivity();
15:	        mFirstTestText =
16:	                (TextView) mFirstTestActivity
17:	                .findViewById(R.id.my_first_test_text_view);
18:	    }

Read More

12:	                mClickFunActivity
13:	                .findViewById(R.id.launch_next_activity_button);
14:	        mInfoTextView = (TextView) 
15:	                mClickFunActivity.findViewById(R.id.info_text_view);
16:	    }

Read More

2:	editText.setOnEditorActionListener(new OnEditorActionListener() {
3:	    @Override
4:	    public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
5:	        boolean handled = false;
6:	        if (actionId == EditorInfo.IME_ACTION_SEND) {

Read More

See Code Examples for Android TextView Methods: