我在使用組展開式和組合式偵聽器的應用程序中使用可展開式列表視圖。 但是會發生什麼情況是組中的右箭頭單擊工作絕對完美,但是當我點擊該行時,組不會在單個clcik中展開。 我必須點擊它多次,只有它擴大。 這裏是擴展列表視圖組的點擊監聽器代碼:Android展開式視圖組展開式偵聽器
expandableListView.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() {
@Override
public boolean onGroupClick(ExpandableListView expandableListView, View view, int i, long l) {
groupName = _groupNameList.get(i);
_header = _child.get(groupName);
if (_header.size() == 1 && _header.get(0).getServiceName().equals(groupName)) {
expandableListView.setGroupIndicator(null);
String id=_header.get(0).getServiceId();
Intent intent = new Intent(CategoryDetails1.this, ServiceSelectionOptionsListActivity.class);
SharedPreferences.Editor editor = CategoryDetails1.this.getSharedPreferences(AppConstants.VERIFICATION, CategoryDetails1.this.MODE_PRIVATE).edit();
editor.putString(AppConstants.SUBSERVICEID, id);
editor.commit();
startActivity(intent);
}
return false;
}
});
,這裏是標題行XML
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_gravity="center"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/tvGroupName"
android:layout_width="match_parent"
android:layout_marginLeft="20dp"
android:textSize="18dp"
android:layout_marginBottom="10dp"
android:textStyle="bold"
android:layout_marginRight="25dp"
android:layout_alignParentLeft="true"
android:inputType="textMultiLine"
android:textColor="@color/selecteditem"
android:layout_marginTop="10dp"
android:layout_height="wrap_content"
android:focusable="false" have tried this
android:layout_weight="1" />
<ImageView
android:id="@+id/groupindicator"
android:layout_width="30dp"
android:layout_marginBottom="10dp"
android:layout_height="30dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:layout_alignParentRight="true"
android:src="@drawable/circle_plus" />
</RelativeLayout>
這是我getgroup觀點方法
public View getGroupView(int groupPosition, boolean b, View view, ViewGroup viewGroup) {
if (view == null) {
view = mLayoutInflater.inflate(R.layout.expandable_list_header, null);
}
TextView tvGroupName = (TextView) view.findViewById(R.id.tvGroupName);
tvGroupName.setFocusable(false); //have tried it also
ImageView ivgroupicon = (ImageView) view.findViewById(R.id.groupindicator);
// ivgroupicon.setImageDrawable(mContext.getResources().getDrawable(R.drawable.servicescollapseicon));
tvGroupName.setText((String) getGroup(groupPosition));
int size = _child.get((String) getGroup(groupPosition)).size();
view.setPadding(0, 10, 0, 10);
if (size == 1 && _child.get((String) getGroup(groupPosition)).get(0).getServiceName().equals((String) getGroup(groupPosition))) {
ivgroupicon.setVisibility(View.GONE);
} else
ivgroupicon.setVisibility(View.VISIBLE);
if (b) {
ivgroupicon.setImageDrawable(mContext.getResources().getDrawable(R.drawable.servicesexpandicon));
} else {
ivgroupicon.setImageDrawable(mContext.getResources().getDrawable(R.drawable.servicescollapseicon));
}
return view;
}
現在我想要什麼是我想在我的活動中平滑的組展開和摺疊監聽器。我已經在我的xml和適配器文件中嘗試了setFocusable爲false,但在Vain中。 所以,大家請儘快給我一些建議。我在很長的一段時間內陷入了困境。
您_child HashMap中沒有包含太多的價值? –
不,它一般包含4-5個值 – Neha