如何使用布局來擴充一個視圖我有一個用XML定義的布局。它還包含:<RelativeLayout
android:id="@+id/item"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>我想用其他XML布局文件來擴充這個RelativeView。我可能會根據情況使用不同的布局。我該怎么辦?我正在嘗試不同的變化RelativeLayout item = (RelativeLayout) findViewById(R.id.item);item.inflate(...)但他們都沒有做好。
3 回答

撒科打諢
TA貢獻1934條經驗 獲得超2個贊
雖然回答很晚,但想補充說明這一點
LayoutInflater layoutInflater = (LayoutInflater)this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View view = layoutInflater.inflate(R.layout.mylayout, item );
這里item
是你想添加一個子布局的父布局。
- 3 回答
- 0 關注
- 502 瀏覽
添加回答
舉報
0/150
提交
取消