2013-07-21 1 views
0

내 XML에 ExpandableListView가 있고 사용자 정의 BaseExpandableListAdapter로 어댑터를 설정하고 있습니다. XML :Android - ExpandableListView가 groupIndicator 아이콘을 표시하지 않습니다.

<ExpandableListView 
    android:id="@+id/expanlist_EstatisticaArsenal" 
    android:divider="@null" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:transcriptMode="alwaysScroll" 
    android:cacheColorHint="#000000" 
    android:listSelector="@android:color/transparent" 
    android:visibility="gone">   
</ExpandableListView> 

android:visibility="gone" 내가 그것을 볼 수 있도록하기 때문에 몇 가지 물건 후

어댑터 사용자 정의 클래스 :

public class Adapter_expanEstatistica extends BaseExpandableListAdapter { 
    private Context c; 
    private List<BlocoArsenal> listblocos; 
    public Adapter_expanEstatistica(Context ctx, List<BlocoArsenal> listBlocos) 
    { 
     c = ctx; 
     listblocos = listBlocos; 
    } 

    @Override 
    public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) 
    { 
     // TODO Auto-generated method stub 
     LayoutInflater inflater = (LayoutInflater) c.getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
     View expdanableView = inflater.inflate(R.layout.estatistica_expanlist_child, null); 

     /* Here i populate a tableLayout that exists in expdanableView with some info */ 

     return expdanableView; 
    } 

    @Override 
    public int getChildrenCount(int groupPosition) { 
     // TODO Auto-generated method stub 
     return 1; 
    } 

    @Override 
    public int getGroupCount() { 
     // TODO Auto-generated method stub 
     return listblocos.size(); 
    } 

    @Override 
    public long getGroupId(int groupPosition) { 
     // TODO Auto-generated method stub 
     return groupPosition; 
    } 

    @Override 
    public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) 
    { 
     // TODO Auto-generated method stub 
     LayoutInflater inflater = (LayoutInflater) c.getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
     View expdanableView = inflater.inflate(R.layout.estatistica_expanlist_parent, null);   
     TextView txt = (TextView) expdanableView.findViewById(R.id.txtNomeBloco); 
     txt.setText(listblocos.get(groupPosition).getNome()); 
     return expdanableView; 
    } 

    @Override 
    public boolean hasStableIds() { 
     // TODO Auto-generated method stub 
     return true; 
    } 

    @Override 
    public boolean isChildSelectable(int arg0, int arg1) { 
     // TODO Auto-generated method stub 
     return false; 
    } 

XML의 ChildView :

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical" >   
      <TableLayout 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:id="@+id/tblEstasticaArsenal" >    
      </TableLayout> 
    </LinearLayout> 

XML의 ParentView :

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:orientation="vertical" > 

    <TextView 
     android:id="@+id/txtNomeBloco" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="3dp" 
     android:layout_marginRight="3dp" 
     android:layout_marginTop="3dp" 
     android:textColor="#5E302A" 
     android:text="Nome Bloco" 
     android:textAppearance="?android:attr/textAppearanceSmall" />  
</LinearLayout> 

내가 expanListView의 어댑터를 설정하고 가시성을 표시로 변경하면 모든 것이 정상적으로 작동하지만 groupIndicator 아이콘이 표시되지 않습니다. 누구든지 나를 도울 수 있습니까?

이 레이아웃 사용하려고 getGroupView 방법
+0

당신은 디스패치 그룹보기를 위해 사용자 정의보기를 사용합니다. 보기 expdanableView = inflater.inflate (R.layout.estatistica_expanlist_parent, null); 이 문제는이보기로 인한 것일 수 있습니다. –

+0

R.layout.estatistica_expanlist_parent는이 게시물의 'XML parentView'코드입니다. 그 안에 textview가 있습니다. 나는 무엇이 될 수 있는지 모른다 = T –

+0

나는이 링크를 따라 가려고했다 : http://myandroidsolutions.blogspot.com.br/2012/08/android-expandable-list-example.html –

답변

1

- 결과로 android.R.layout.simple_expandable_list_item_2

를, 당신의 코드는 다음과 같이 표시됩니다

@Override 
public View getGroupView(int groupPosition, boolean isExpanded, View theConvertView, ViewGroup parent) 
{ 
    View row = theConvertView; 
    TextView textView; 

    if(theConvertView == null) { 
     row = inflater.inflate(android.R.layout.simple_expandable_list_item_2, null); 
     textView = (TextView)row.findViewById(android.R.id.text2); 
     row.setTag(textView); 
    } else { 
     textView = (TextView)theConvertView.getTag(); 
    } 

    //textView.setText(); //TODO set group 

    return row; 
} 

을이 방법에서 diferrent입니다 볼 수 있다면 너의. 나는 ViewHolderPatter를 사용했다.이 코드는 더 잘 작동한다.

내 그룹 표시기에서 확인했습니다.

희망, 도와 드리겠습니다.

+0

그것은 작동하지 않았다 =/나 새로운 Android 애플리케이션을 만들었고이 코드를 다시 만들었습니다. http://myandroidsolutions.blogspot.com.br/2012/08/android-expandable-list-example.html 자습서에서 정확히 어떻게 말 했나요? 그룹 아이콘이 표시되지 않았습니다. D : - http://img850.imageshack.us/img850/5391/bbhu.png - 내 IDE/에뮬레이터의 버그 일 수 있습니까? –

+0

사용자 정의 그룹 아이콘을 만들었는데 이유를 모르지만 작동합니다. 도와 주셔서 감사합니다. –

+0

문제 없습니다, 행운을 비네! –