0
可能重複:
Android Problem calling TextView from second layout file的Android findViewById()的問題
嘿,夥計們對我的活動主要佈局在XML文件R.layout.date_list_layout,因爲它被用作如下
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.date_list_layout);
但是我希望在另一個佈局xml f中設置TextView中的文本來自同一活動ILE R.layout.display_item
我知道我通常會用下面的代碼,但是這是不工作的R.id.currency TextView的是不在主R.layout.date_list_layout ....
TextView currency = (TextView) findViewById(R.id.currency);
currency.setText(cur);
我知道下一行代碼不正確,但是有沒有辦法編寫類似的代碼行來訪問R.layout.display_item xml中的R.id.currency,或者可以這樣做嗎?
TextView currency = (TextView) findViewById(R.layout.display_item/R.id.currency);
currency.setText(cur);
一些幫助真的可以理解,因爲這有我猛然一驚的最後兩天,我不能在網上找到任何解決方案
感謝 一個