miércoles, 22 de julio de 2015

2.5 añadir texto adicional con addView

Para añadir texto adicional se necesita  crear un LinearLayout en el archivo xml

<LinearLayout
        android:id="@+id/myLinearLayout"
        android:orientation="vertical"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        >
</LinearLayout>

y en el archivo java agregar el siguiente código:


myTexto.setText("He modificado un TextView con un nuevo texto usando Java");
TextView tv= new TextView(this);
tv.setTextColor(Color.argb(255, 0, 0, 0));
tv.setTextSize(40);
tv.setText("Añadiendo nuevo texto con addView");
LinearLayout ll=(LinearLayout) findViewById(R.id.myLinearLayout);
ll.addView(tv); 



No hay comentarios:

Publicar un comentario