Clearing TextView in Android -
i'm facing problem textview. not erasing previous instances of data.
when i'm running application in emulator displays output data in textview. that's fine. when i'm clicking button in emulator , re opening application not clear previous data. instead appends data existing data.
any appreciated.
my code below:
public class mainactivity extends actionbaractivity { private textview mtextview; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); mtextview = (textview) findviewbyid(r.id.text_test); new thread(new testlocalhost()).start(); } private class testlocalhost implements runnable { @override public void run() { final string s = jsonparser.doget("http://192.168.0.107:15071/getresult.ashx?op=getinfo",null); runonuithread(new runnable() { @override public void run() { mtextview.settext(s); } }); } } }
it's happening because app still lives in emulator memory, need force kill if want app run again scratch.
you should click on "running processes" button , swipe left/right app process.
in scenario described activity wasn't destroyed yet, , when reopen onresume() method being called.
Comments
Post a Comment