android - get a string value from a thread -
can tell me, how stringvalue thread mainactivity?
i have thread this:
public class xmlhandler extends defaulthandler { xmldatacollected data = new xmldatacollected(); ...... ...... public string getinformation() { string information = ""; if (data.getdata().equals("residential")) { information = "stadt"; } return information; } }
in mainactivity tried set value textview this:
textview.settext(xmlhandler.getinformation());
i not work after all. doing wrong? solutions , advices? in advance
if have separatethread class need create 1 interface say
public interface fetchvaluelistener{ public void sendvalue(string value_to_send); }
and acctivity implementing interface , sendvalue(value_to_send) method added activity.
next step when create object of thread class need pass object of interface in paramater follows:
public class mythreadclass{ fetchvaluelistener mllistener; mythreadclass(fetchvaluelistener listenerobj){ mllistener=listenerobj; } }
now when want send value activity thread can call
mllistener.sendvalue(value_you_wan_to_send);
and inside actiivty value in sendvalue() method..
in method need post data runnable using handler can make changes ui settext etc..... if directly try set value of text view in method exception.
Comments
Post a Comment