2011-05-05 2 views
0

문제가 있습니다.재 팽창하는 Viewstub

2 개의 뷰 스텁이있는 두 영역에서 내 화면을 감습니다.

그러나 ViewStub을 비정상적으로 확장하면 더 이상 액세스 할 수 없으며이 ViewStub 내에서 다른 View를 팽창시킬 수 없습니다.

그래서 이러한 종류의 컨테이너를 사용하는 대안이 무엇입니까?

여기 몇 가지 코드가 있습니다. 당신의 모든 사랑 코드 : 여기

ViewStub contentSpace = (ViewStub) findViewById(R.id.ContentSpace);  
    contentSpace.setLayoutResource(R.layout.view1); 
    contentSpace.inflate(); 
    contentSpace.setInflatedId(R.id.Content); 
    RelativeLayout content = (RelativeLayout) findViewById(R.id.Content); 

    contentSpace.setLayoutResource(R.layout.view1); //crash 
    contentSpace.inflate(); 
+0

이 도움이 될까요? http://stackoverflow.com/questions/5342121/inflate-a-view-layout-into-another-layout/5343733#5343733 – bigstones

답변

0

내 솔루션

rootLayout는 ViewStubs이 위치하고 있었다 수있는 선형 레이아웃입니다.

rootLayout.removeView(contentLayout); 
    inflater.inflate(R.id.view1, rootLayout); 
    contentLayout = findViewById(R.id.contentLayout); 

뷰 1이 : ViewStub가 다시 팽창 될 수없는 것처럼

<?xml version="1.0" encoding="utf-8"?> 
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:orientation="horizontal"  
     android:id="@+id/contentLayout"> 
[...]