my application keeps force closing. But Eclipse shows no error or warnings
package com.example.pkg;
import android.os.Bundle;
import android.widget.TextView;
import android.app.Activity;
public class subActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sub);
Thread r = new Thread(new Runnable(){
public void run()
{ final TextView tv=(TextView)findViewById(R.id.rline1);
String s=(String)tv.getText();
tv.setText(s+"Works !");
}
});
r.start();
}
}
Another Activity calls this Activity. That one has the TextView displayed. All I want to do is to change this string resource called R.string.rline1 that is being displayed on the TextView. Please tell me how to do this if there is another way
First thing, you must need to update GUI stuffs inside UI thread else it will never work. Second thing you know how many times you are creating the instance of your text view and setting it again again, you are inside the thread and you havn’t set any flag to stop your thread once you are done. E.g for UI thread :