2013-07-30 1 views

답변

4

런타임에서 당신은 예를 들어, 인플레이터를 사용할 수 있습니다

Inflater inflater = LayoutInflater.from(this); 
View view = inflater.inflate(R.layout.intro_step1_activity, null); 

후 현재 뷰 계층이보기를 추가 할 수 있습니다. 컴파일 시간에 당신은 먼저 idLinearLayout 것과을주는 XML

<include layout="@layout/intro_step1_activity"/> 
+0

에 대한 다른 XML 파일을 사용 <include />

의 XML 파일을 사용하여 읽을 수 있습니다 : 그것은이다 직접적으로 사용한 적이 없다. 대신에 getLayoutInflater() 또는 getSystemService (String)를 사용하여 이미 현재 컨텍스트에 연결되어 있고 실행중인 장치에 대해 올바르게 구성되어있는 표준 LayoutInflater 인스턴스를 검색하십시오. 예 : LayoutInflater inflater = (LayoutInflater) context.getSystemService (Context.LAYOUT_INFLATER_SERVICE); – LightMan

0

의 태그를 포함 사용하고 자바에서 LinearLayout을 정의하고 findViewById() 방법을 사용하여 참조 할 수 있습니다.

방금 ​​만든 LinearLayout 개체를 사용하여 addView() 메서드를 호출합니다.

예를 들어 싶은 경우 의견을 보내주십시오.

0

예, <merge> 또는 <include>을 사용할 수 있습니다.

좀 더 here

3
Load an existing xml layout file in another xml layout file 

here 안드로이드 문서에서 당신의 intro_step1_activity.xml 코드를 사용

<include layout="intro_step1_activity.xml"/>