I'm trying to setText a new value to my TextView from a non activity class by inflating the layout where the textview is, but I'm still unsuccessful though I'm able to getText the current value of the TV. Here's the code:
LayoutInflater mInflater = (LayoutInflater) mContext.getSystemService(mContext.LAYOUT_INFLATER_SERVICE);
View view = mInflater.inflate(R.layout.target_details, null);
TextView val = (TextView) view.findViewById(R.id.val);
Not sure if I'm doing it properly.
UPDATE: I used Kay's answer with added code below. It's now working.
((Activity)mContext).runOnUiThread(new Runnable(){
@Override
public void run(){
//settext here
}
});