TextView setText - top ranked examples from Open Source projects

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

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;
       
9
CodeRank
Contextual code suggestions in your IDE  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) {
8
CodeRank
Contextual code suggestions in your IDE  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;
        } 
 
    } 
} 
9
CodeRank
Contextual code suggestions in your IDE  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
Contextual code suggestions in your IDE  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:setLayoutParams, setCompoundDrawablesWithIntrinsicBounds, setGravity, setPadding, setText
			} catch (NameNotFoundException e) {
				return 0; 
			} 
        } 
        public TextView getGenericView() {
            TextView textView = new TextView(ActivityPickerActivity.this);
            textView.setLayoutParams(lpGroup);
            textView.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT);
            textView.setPadding(leftPadding, 0, 0, 0);
            return textView;
        } 
        public View getChildView(int groupPosition, int childPosition, boolean isLastChild,
                View convertView, ViewGroup parent) {
            TextView textView = getGenericView();
            ActivityInfo activity=getChild(groupPosition, childPosition);
            if(activity!=null){
	            String name=activity.name.replace(activity.packageName, "");
	        	textView.setText(activity.loadLabel(mPackageManager)+"("+name+")");
	        	textView.setLayoutParams(lpChild);
            } 

8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
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
Contextual code suggestions in your IDE  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;
	} 
8
CodeRank
Contextual code suggestions in your IDE  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;
        } 
 
    } 
} 
 
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setLayoutParams, setGravity, setPadding, setText
        public TextView getGenericView() {
            // Layout parameters for the ExpandableListView 
            AbsListView.LayoutParams lp = new AbsListView.LayoutParams(
                    ViewGroup.LayoutParams.MATCH_PARENT, 64);
 
            TextView textView = new TextView(ExpandableList1.this);
            textView.setLayoutParams(lp);
            // Center the text vertically 
            textView.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT);
            // Set the text starting position 
            textView.setPadding(36, 0, 0, 0);
            return textView;
        } 
         
        public View getChildView(int groupPosition, int childPosition, boolean isLastChild,
                View convertView, ViewGroup parent) {
            TextView textView = getGenericView();
            textView.setText(getChild(groupPosition, childPosition).toString());
            return textView;
        } 

8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java

Related TextView setText Questions & Answers:

Other TextView setText Examples

15:	          s += "vogella.com ";
16:	        }
17:	        view.setText(s);
18:	    }
19:	}

Read More

51:	    String string = button.getText().toString();
52:	    int hitTarget = Integer.valueOf(string) + 1;
53:	    button.setText(String.valueOf(hitTarget));
54:	  }
55:

Read More

37:	      onLocationChanged(location);
38:	    } else {
39:	      latituteField.setText("Location not available");
40:	      longitudeField.setText("Location not available");
41:	    }
-
38:	    } else {
39:	      latituteField.setText("Location not available");
40:	      longitudeField.setText("Location not available");
41:	    }
42:	  }
-
60:	    int lat = (int) (location.getLatitude());
61:	    int lng = (int) (location.getLongitude());
62:	    latituteField.setText(String.valueOf(lat));
63:	    longitudeField.setText(String.valueOf(lng));
64:	  }
-
61:	    int lng = (int) (location.getLongitude());
62:	    latituteField.setText(String.valueOf(lat));
63:	    longitudeField.setText(String.valueOf(lng));
64:	  }
65:

Read More

31:	
32:			// Diplaying the text
33:			txtPlayCount.setText(now_playing);
34:			txtEarned.setText(earned);
35:		}
-
32:			// Diplaying the text
33:			txtPlayCount.setText(now_playing);
34:			txtEarned.setText(earned);
35:		}
36:	}

Read More

52:	         
53:	        imgIcon.setImageResource(navDrawerItems.get(position).getIcon());        
54:	        txtTitle.setText(navDrawerItems.get(position).getTitle());
55:	        
56:	        // displaying count
-
57:	        // check whether it set visible or not
58:	        if(navDrawerItems.get(position).getCounterVisibility()){
59:	        	txtCount.setText(navDrawerItems.get(position).getCount());
60:	        }else{
61:	        	// hide the counter view

Read More

82:			List<String> lables = new ArrayList<String>();
83:			
84:			txtCategory.setText("");
85:	
86:			for (int i = 0; i < categoriesList.size(); i++) {

Read More

setText Method Overview
See Code Examples for other Android TextView Methods: