2013-08-01 4 views
1

DraggableGridViewfrom here을 사용하고 있습니다.팽창 된 레이아웃의 자식이 표시되지 않습니다.

앞서 프로그래밍 방식으로 작성된 ImageViews을 그리드에 추가했습니다. 그건 완벽하게 잘 작동합니다.

이제 Layout을 추가하려고합니다. 나는 RelativeLayout, Framelayout, 안에 FrameLayout 안에 시도했다.

/** 
* Rebuild the grid view, e.g. after the adapter has been filled or a backup is restored 
*/ 
private void renewGrid() 
{ 
    dgv.removeAllViews(); 
    for(int i = 0; i < adapter.getCount(); i++) 
    { 
     LayoutInflater inflater = (LayoutInflater)ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
     dgv = (DraggableGridView) inflater.inflate(R.layout.grid_item_layout, dgv); 
     FrameLayout fl = (FrameLayout) dgv.findViewById(R.id.grid_images); 
     ImageView icon = (ImageView) fl.findViewById(R.id.qstile); 
     icon.setImageDrawable(res.getDrawable(res.getIdentifier("qstile_" + adapter.getItem(i), "drawable", packagename))); 
    } 
} 

grid_item_layout 다음과 같습니다 :

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:gravity="center_vertical" 
    android:orientation="horizontal" > 

    <FrameLayout 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:id="@+id/grid_images"> 
     <ImageView 
      android:layout_width="32dp" 
      android:layout_height="32dp" 
      android:src="@drawable/icon_delete"/> 

     <ImageView 
      android:id="@+id/qstile" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content"/> 
    </FrameLayout> 

    <TextView 
     android:id="@+id/invisible_text" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="center" 
     android:text="" 
     android:visibility="gone" /> 

</RelativeLayout> 

RelativeLayout 멋지게 그리드로 팽창됩니다

여기에 지금과 같은 내 코드입니다. 나는 DDMS와 "Dump view hierachy"기능을 통해 이것을 관찰 할 수있다. 트리에는 모눈 안의 모든 RelativeLayouts가 표시되지만 각 자식에는 자식이 없습니다.

하지만 ... 사실이 아닙니다. 코드를 단계별로 실행하고 부풀려진 레이아웃을 관찰하면 아이들을 볼 수 있습니다. 그래서 그들은 설정되어 XML에서 말한 것처럼 추가되지만 그려지지는 않습니다. 또한 작동 그리드의 자녀에

OnItemClick listener ...

내가 여기에 누락 대해 어떤 힌트? 이미 여러 가지 방법을 시도해 보았습니다. 프로그래밍 방식으로 전체 레이아웃을 만든 다음 그리드를 자식으로 추가했습니다. 아직도 운이 없다. 아이들은 하나도 추가되지 않습니다.

DraggableGridView에 문제가 있습니까?

답변

2

다른 몇 시간 동안 검색 한 후 나는 기본적으로 내가 지금 FrameLayout보다는 ViewGroup에서 DraggableGridView을 확장 this SO thread

의 수정을 발견했다. 이것은 저에게 어떤 두드러진 부작용도 없었습니다.

+1

당신은 저를 구원했습니다. :) –

관련 문제