我想删除集团在我的扩展列表中选择时,并有刷新删除后发生的清单。
I am trying to delete Group when selected in my Expandable List, and having the list refreshed after the delete occurred.
我把源$ C $ c从谷歌:
I took the source code from google:
http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/view/ExpandableList1.html
我试过几种方法来删除它,但没有成功,任何人都取得了吗?
I tried couple of ways to delete it, but no success, anyone achieved that already?
谢谢, 射线。
推荐答案
回答第二个问题(添加行了孩子和放大器;数据结构)
Answer for the second question (Add rows to a child & datastructure)
有关的数据结构网络化:
For the Datastructure:
public class GroupItem {
private String mItemText;
private List<ChildItem> mChildItems=new ArrayList<ChildItem>();
public GroupItem(String itemText) {
mItemText=itemText;
}
public String getItemText() {
return mItemText;
}
public ChildItem getChild(int childPosition) {
return mChildItems.get(childPosition);
}
public void addChild(ChildItem childItem) {
return mChildItems.add(childItem)
}
public void removeChild(int childPosition) {
return mChildItems.remove(childPosition);
}
}
public class ChildItem {
private String mItemText;
public ChildItem(itemText) {
mItemText=itemText;
}
public String getItemText() {
return mItemText;
}
}
现在设置它,你会做这样的事情:
Now to set it up you would do something like:
List<GroupItem> items = new ArrayList<GroupItem>();
GroupItem item1 = new GroupItem("This is group 1");
item1.addChild(new ChildItem("This is a child item of group 1"));
item1.addChild(new ChildItem("This is another child item of group 1"));
等等...
and so on...
那么,在适配器你需要返回相应的数据。
Then, in the Adapter you would need to return the appropriate data.
有关您的有关问题行: 在你的谷歌的例子,它们返回一个TextView。但是你可以让自己的布局与你喜欢的任何内容。例如:
For your question concerning rows: In your Google example, they return a TextView. You can however make your own Layout with whatever content you like. For example:
<ImageView android:id="@+id/RowIcon"
android:layout_width="56px"
android:layout_height="56px"
android:layout_marginLeft="12px"
android:layout_marginTop="2px">
</ImageView>
<TextView android:id="@+id/RowTextView"
android:paddingLeft="10px"
android:paddingTop="10px"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:textColor="#666666" android:textSize="14px"/>
</LinearLayout>
然后用这个布局在您的适配器。而不是返回,也就是说,一个TextView的,你只返回这是一个查看:
And then use this Layout in your Adapter. Instead of returning, say, a TextView, you'll just return this as a View:
public View getChildView(int groupPosition, int childPosition, boolean isLastChild,
View convertView, ViewGroup parent) {
LayoutInflater mInflater = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View rowView = mInflater.inflate(YOUR XML FILE FROM ABOVE, null);
ImageView rowIcon = (ImageView)rowView.findViewById(R.id.RowIcon);
iconType.setBackgroundResource(AN IMAGE HERE);
TextView rowText =(TextView)rowView.findViewById(R.id.RowTextView);
textAddress.setText(items.get(groupPosition).getChild(childPosition));
return rowView;
}
所以,我觉得应该让你去。
So, i think that should get you going.
此外,请接受我的回答如果你满意他们。
Also, please accept my answers if they satisfy you.
干杯。
相关推荐
最新文章