Android - изменение textView во время выполнения

Я работаю с линейным макетом и пытаюсь изменить текст TextView, но он не обновляется. При отладке я проверил, что текст изменился правильно.

Спасибо

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.
         ....
    }

Здесь я публикую код xml файла. Это действительно глупо, но это может быть проблемой:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">


    <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">
    </TextView>
    <Button android:layout_height="wrap_content" 
        android:id="@+id/Empezar" android:text="Empezar" 
        android:layout_width="fill_parent" 
        android:layout_marginTop="20dip">
    </Button>
    <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">
    </Button>


</LinearLayout>

Я отредактировал сообщение, потому что я опустил часть кода, чтобы упростить его, но я думаю, что могу также устранить проблему. Он работает в бесконечном цикле, может быть это ошибка?

1
задан Miguel 17 September 2010 в 11:47
поделиться