我在我的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嘗試使用此佈局
您使用自定義視圖來顯示組視圖.. 查看expdanableView = inflater.inflate(R.layout.estatistica_expanlist_parent,null); 這個問題可能是由於這個觀點。 –
R.layout.estatistica_expanlist_parent是這篇文章中的'XML parentView'代碼。它裏面只有一個textview。我不知道什麼可以= T –
我試圖按照此鏈接:http://myandroidsolutions.blogspot.com.br/2012/08/android-expandable-list-example.html –