Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid - change textView at run time
    primarykey
    data
    text
    <p>I´m working with a lineal layout and I´m trying to change the text of a TextView but it doesn´t refresh. When I debug I´ve checked that the text have changed correctly.</p> <p>Thanks</p> <pre><code>public class Position extends Activity { Button botonempezar; Button botonsalir; TextView text; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.position); botonsalir = (Button) findViewById(R.id.salir); botonempezar = (Button) findViewById(R.id.Empezar); text = (TextView) findViewById(R.id.Textoposicion); botonsalir.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { onDestroy(); finish(); } }); botonempezar.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub searchPosition(); } }); } private void searchPosition(){ boolean condition = true; do{ determinatePosition(); }while(condition == true); } private void determinatePosition(){ .... this.text.setText("New text"); //this.text.invalidate(); this.text.postInvalidate(); Toast.makeText(getBaseContext(), "New text", Toast.LENGTH_SHORT);// this doesnt work neither. .... } </code></pre> <p>Here I post the code of the xml file. Its really silly but it could be the problem:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"&gt; &lt;TextView android:layout_height="wrap_content" android:id="@+id/Textoposicion" android:text="Posición desconocida" android:layout_width="fill_parent" android:layout_marginTop="20dip" android:inputType="text"&gt; &lt;/TextView&gt; &lt;Button android:layout_height="wrap_content" android:id="@+id/Empezar" android:text="Empezar" android:layout_width="fill_parent" android:layout_marginTop="20dip"&gt; &lt;/Button&gt; &lt;Button android:layout_height="wrap_content" android:id="@+id/salir" android:layout_marginTop="20dip" android:text="Finalizar programa" android:gravity="center" android:layout_width="fill_parent"&gt; &lt;/Button&gt; &lt;/LinearLayout&gt; </code></pre> <p>I have edited the post because I omitted part of the code to make it simpler but I think I may suppressed the problem too. It runs in a endless loop, could be this the mistake?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload