我的 xml 中有一个 ExpandableListView,我正在使用自定义 BaseExpandableListAdapter 设置它的适配器。XML:
<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 子视图:
<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 父视图:
<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 图标。任何人都可以帮助我吗?