android - I am trying to update a textview from a different activity and it keeps crashing -
on button click reading information file , need display in textview, code works while in activity layout if in different screen same code doesn't work.
string sdcard = environment.getexternalstoragedirectory().getabsolutepath(); file file = new file(sdcard + "/mult/","boardname.cfg"); //read text file try {     bufferedreader br = new bufferedreader(new filereader(file));     string line;    while ((line = br.readline()) != null) {        global.defaultboard = line;    }    textview defaultboard = (textview) findviewbyid(r.id.currentboard);    defaultboard.settext(global.defaultboard); }     catch (ioexception e) {     //you'll need add proper error handling here }  finish(); can see whats wrong? if remove lines aor comment lines of textview doesn't crash.
thanks
mrc
ok
my solution - value stored in global variable use onresume() refresh textview.
public void onresume() {          super.onresume();          textview defaultboard = (textview) findviewbyid(r.id.currentboard);          defaultboard.settext(global.defaultboard);  } mrc
you can update ui views when running in main thread. if stuff in different thread use runonuithread method of activity passing little runnable actual work.
Comments
Post a Comment