Answers for "how to set textview programmatically in android"

2

how to create textview programmatically in android

String[] textArray = {"One", "Two", "Three", "Four"};
LinearLayout linearLayout = new LinearLayout(this);
setContentView(linearLayout);
linearLayout.setOrientation(LinearLayout.VERTICAL);        
for( int i = 0; i < textArray.length; i++ )
{
    TextView textView = new TextView(this);
    textView.setText(textArray[i]);
    linearLayout.addView(textView);
}
Posted by: Guest on November-08-2020
0

setdrawableTint of textview programmatically android

private void setTextViewDrawableColor(TextView textView, int color) {
        for (Drawable drawable : textView.getCompoundDrawables()) {
            if (drawable != null) {
                drawable.setColorFilter(new PorterDuffColorFilter(ContextCompat.getColor(textView.getContext(), color), PorterDuff.Mode.SRC_IN));
            }
        }
    }
Posted by: Guest on July-31-2020

Code answers related to "how to set textview programmatically in android"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language