10
A
回答
21
我首選的處理方式通脹:
//First get our inflater ready, you'll need the application/activity context for this
LayoutInflater mInflater;
mInflater = LayoutInflater.from(mContext);
//Inflate the view from xml
View newView = mInflater.inflate(R.layout.my_new_layout, null);
//Then you'll want to add it to an existing layout object
mMainLayout.add(newView);
//Or perhaps just set it as the main view (though this method can also
// inflate the XML for you if you give it the resource id directly)
setContentView(newView);
基本上,你用它在運行時膨脹,現有的XML佈局。通常你會繼續將這些新視圖插入到先前定義的ViewGroups或List對象中。
6
不太清楚你的意思,但如果它與膨脹視圖相關,它用來將佈局xml文件加載到你的應用程序中。例如通過
View myWelcome = View.inflate(this, R.layout.welcome, null);
它更容易,並考慮最佳實踐,讓您查看佈局XML文件中的定義,而不是完全由代碼創建您的意見。
2
佈局充氣用於返回你的完整佈局的java對象
假設你有一個佈局XML文件中的根元素是相對佈局,它包含一個imageview的並且TextView的再利用佈局充氣機可以退貨一個引用整個佈局的視圖對象。
這基本上用於列表視圖和網格視圖,以將它們插入單個行或要重複的元素的佈局對象。
0
你問的使用充氣.. 基本上當你想在一個Java類中使用兩個XML文件,充氣機被使用,它的代碼是在下面給出簡單..
TextView text;
View layout;
LayoutInflater inflator=getLayoutInflater();
layout =inflator.inflate(R.layout.new_xml_that you want to use in that java class,null);
text=(TextView)layout.findViewById(R.id.text);
text.setText("progressing");
這裏我用的TextView,這是目前在與ID爲下XML =文本 完蛋了。如果您發現該對得起那麼請這樣的.. 感謝
相關問題
- 1. 本機Android WebRTC應用程序開發
- 2. 爲Android開發手機應用程序
- 3. Android應用程序開發 - 相機應用程序的問題
- 4. Android應用程序中的佈局充氣器是什麼?
- 5. 如何在android Google Map上開發天氣應用程序?
- 6. 開發android應用程序
- 7. android應用程序開發
- 8. Android開發應用程序
- 9. Android應用程序開發
- 10. Android應用程序開發
- 11. Android應用程序開發
- 12. Android應用程序開發
- 13. Android開發中的FM收音機應用程序
- 14. 關於Android應用程序的菜單充氣器項目
- 15. 在xcode中開發android應用程序
- 16. 在Android中開發iPad應用程序
- 17. 在android中開發web應用程序
- 18. 在android中開發unicode應用程序
- 19. Android開發應用程序在應用程序中不可見
- 20. 發生Android充氣異常
- 21. 如何在Docker中開發Erlang氮氣應用程序
- 22. 幫助Web應用程序開發和手機應用程序/遊戲開發
- 23. PowerBuilder上的Android應用程序開發
- 24. Eclipse的Android應用程序開發
- 25. Android的應用程序開發像facebook
- 26. Android上的NFC應用程序開發
- 27. 開發應用程序到手機
- 28. 智能手機應用程序開發
- 29. 黑莓手機應用程序開發
- 30. iPhone手機應用程序開發
+1最高分,一個偉大的回答言簡意賅,感謝 – 2011-08-22 19:23:45
@Marloke很有幫助的人 – 2012-07-21 11:23:40