2
我試圖得到一個定製Expandablelistview,有不同的佈局狀態展開/摺疊...expandablelistview不同風格的展開/摺疊
適配器
@Override
public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
String headerTitle = ((User) getGroup(groupPosition)).getName();
if (convertView == null) {
LayoutInflater infalInflater = (LayoutInflater) this.con.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
if(isExpanded) {
Log.e("DBG", "isExpanded");
convertView = infalInflater.inflate(R.layout.expanablelistview_header_expanded, parent, false);
} else {
Log.e("DBG", "isNotExpanded");
convertView = infalInflater.inflate(R.layout.expanablelistview_header_collapse, parent, false);
}
}
TextView lblListHeader = (TextView) convertView.findViewById(R.id.tv_user);
lblListHeader.setTypeface(null, Typeface.BOLD);
lblListHeader.setText(headerTitle);
return convertView;
}
expanablelistview_header_collapse.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/transparent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/xml_border"
android:orientation="vertical" >
<TextView
android:id="@+id/tv_user"
android:textSize="20sp"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<View
android:background="@color/transparent"
android:layout_width="match_parent"
android:layout_height="10dp" />
</LinearLayout>
expanablelistview_header_expanded.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/xml_border_top"
android:orientation="vertical" >
<TextView
android:id="@+id/tv_user"
android:textSize="20sp"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
這是我的嘗試,但這種梅索德只呼籲啓動不是在擴展狀態變更...
謝謝你,你的想法!
一舉兩得佈局包含哪些佈局? – 2015-03-02 14:24:14
添加Layout xml的 – Flo 2015-03-02 14:37:28
而不是更改佈局,您可以隱藏並顯示您的「視圖」並更改線性佈局的背景。 – 2015-03-02 14:40:33