我希望能夠遍歷xml佈局文件列表,而不必在setContentView參數中指定特定的佈局文件。有沒有辦法動態設置setContentView(int id)?
明顯的類型是不正確的,但這樣的:
ArrayList<String> pages = new ArrayList<String>();
//(Where each of the xml pages are stored like R.layout.page1, R.layout.page2, etc)
setContentView(pages.get(0));
這可能不知?
你想達到什麼視覺效果? –
@Sergey Rudchenko我只需要能夠根據需要加載儘可能多的xml佈局文件,並循環顯示它們,而無需爲每個佈局文件編寫獨立的活動類。 – Neeta
這可能是某種可重用的活動類。但仍不清楚目標是什麼。 –