2
我想要從服務訪問findViewById()
而不將它作爲服務的構造函數中的參數或意圖傳遞,這可能嗎?從服務訪問findViewById
她我的代碼:
public class ManageDataService extends Service implements LocationListener {
public void onCreate() {
TextView longitudeField = (TextView) findViewById(R.id.overview_position_longitude);
}
}
我必須得到活動的背景下不知怎麼的,對不對?
我在互聯網上沒有找到任何匹配的解決方案。
你不想這樣做。服務更新您的數據模型。活動讀取模型並更新其視圖。 – 2013-04-07 10:23:27
@MaciejGórski好的,我明白了。 – felixd 2013-04-07 13:34:44