public class SimpleExpandableListAdapterwithwebitem extends BaseExpandableListAdapter { private List> mGroupData; private int mExpandedGroupLayout; private int mCollapsedGroupLayout; private String[] mGroupFrom; private int[] mGroupTo;
private List<? extends List<? extends Map<String, ?>>> mChildData;
private int mChildLayout;
private int mLastChildLayout;
private String[] mChildFrom;
private int[] mChildTo;
int groupPositionitem;
int childhight;
int grouphight;
int child;
private LayoutInflater mInflater;
public SimpleExpandableListAdapterwithwebitem(Context context,
List<? extends Map<String, ?>> groupData, int groupLayout,
String[] groupFrom, int[] groupTo,
List<? extends List<? extends Map<String, ?>>> childData,
int childLayout, String[] childFrom, int[] childTo) {
this(context, groupData, groupLayout, groupLayout, groupFrom, groupTo, childData,
childLayout, childLayout, childFrom, childTo);
}
public SimpleExpandableListAdapterwithwebitem(Context context, List> groupData, int expandedGroupLayout, int collapsedGroupLayout, String[] groupFrom, int[] groupTo, List>> childData, int childLayout, String[] childFrom, int[] childTo) { this(context, groupData, expandedGroupLayout, collapsedGroupLayout, groupFrom, groupTo, childData, childLayout, childLayout, childFrom, childTo); } public SimpleExpandableListAdapterwithwebitem(Context context, List> groupData, int expandedGroupLayout, int collapsedGroupLayout, String[] groupFrom, int[] groupTo, List>> childData, int childLayout, int lastChildLayout, String[] childFrom, int[] childTo) { mGroupData = groupData; mExpandedGroupLayout = expandedGroupLayout; mCollapsedGroupLayout = collapsedGroupLayout; mGroupFrom = groupFrom; mGroupTo = groupTo;
mChildData = childData;
mChildLayout = childLayout;
mLastChildLayout = lastChildLayout;
mChildFrom = childFrom;
mChildTo = childTo;
mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
public Object getChild(int groupPosition, int childPosition) { return mChildData.get(groupPosition).get(childPosition); }
public long getChildId(int groupPosition, int childPosition) { return childPosition; }
public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) { View v; groupPositionitem=groupPosition; //Log.v("groupPosition", "groupPosition"+groupPositionitem); if (convertView == null) { v = newChildView(isLastChild, parent); } else { v = convertView; } // mGroupData.setSelectionFromTop(groupPositionitem, 1); child=v.getHeight(); childhight=0+child; Log.v("mChildData", "mChildData"+v.getHeight()); bindView(v, mChildData.get(groupPosition).get(childPosition), mChildFrom, mChildTo,true); return v; }
public View newChildView(boolean isLastChild, ViewGroup parent) { return mInflater.inflate((isLastChild) ? mLastChildLayout : mChildLayout, parent, false); }
private void bindView(View view, Map data, String[] from, int[] to, boolean IsChild)
{
int len = to.length;
Log.v("len", "len"+len);
for (int i = 0; i < len; i++)
{
/* if(i/
/ if(i == len - 2)
{
Log.v("len", "lenxxy"+ to[i] + " " + from[i] );
WebView wv=(WebView)view.findViewById(to[i]);
if (wv != null) {
wv.loadData((String)data.get(from[i]), "text/html", "UTF-8");
}
} */
if (IsChild)
{
for (int k =0; k <=groupPositionitem; k++)
{
if(k == groupPositionitem)
{
// Log.v("groupPosition11", "groupPosition888"+i+len);
// Log.v("len", "Child"+ to[i] + " " + from[i]);
WebView wv=(WebView)view.findViewById(to[i]);
// TextView tv=(TextView)view.findViewById(to[i]);
// wv.setBackgroundColor(0);
//wv.getSettings().setJavaScriptEnabled(true);
// wv.addJavascriptInterface(new DemoJavaScriptInterface(), "demo");
if (wv != null) {
if(groupPositionitem==3)
{
Log.v("groupPosition333", "groupPosition3333333333333333");
startItem();
}else
{
//Log.v("childdata",+childhight+ "childata"+grouphight);
//scroll.scrollTo(0,childhight+grouphight);
wv.loadDataWithBaseURL("fake://not/needed",(String)data.get(from[i]), "text/html", "UTF-8","");
Log.v("groupPosition333", "groupPosition3333333333333333"+wv.getScrollY());
}
}
}
}
}
else
{
if(i == len - 1)
{
TextView v = (TextView)view.findViewById(to[i]);
if (v != null)
{
v.setText((String)data.get(from[i]));
}
}
}
}
}
public int getChildrenCount(int groupPosition) { return mChildData.get(groupPosition).size(); }
public Object getGroup(int groupPosition) { return mGroupData.get(groupPosition); }
public int getGroupCount() { return mGroupData.size(); }
public long getGroupId(int groupPosition) { return groupPosition; }
public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) { View v; if (convertView == null) { v = newGroupView(isExpanded, parent); } else { v = convertView; } grouphight=v.getHeight(); Log.v("mGroupData", "mGroupData"+v.getHeight()); bindView(v, mGroupData.get(groupPosition), mGroupFrom, mGroupTo,false); return v; }
public View newGroupView(boolean isExpanded, ViewGroup parent) { return mInflater.inflate((isExpanded) ? mExpandedGroupLayout : mCollapsedGroupLayout, parent, false); }
public boolean isChildSelectable(int groupPosition, int childPosition) { return true; }
public boolean hasStableIds() { return true; }
}