我想通过膨胀textview的布局来设置TextTextText从一个非活动类的新值,但我仍然不成功,虽然我能够getText电视机的当前价值。这里是代码:更改来自非活动类的TextView值
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);
不知道我是否正确地做。
更新: 我用Kay的答案添加了下面的代码。它正在工作。
((Activity)mContext).runOnUiThread(new Runnable(){
@Override
public void run(){
//settext here
}
});
如何活动和相关的类。 –