Android TextView example

Example 1: get text from textview android

String a = tv.getText().toString();
     int A = Integer.parseInt(a);

Example 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);
}

Example 3: how to create textview in java android

TextView textView = new TextView(this);

Tags:

Misc Example