android删除Item以后怎么立即刷新
2个回答
展开全部
//设置子项点击监听器
listview.setOnItemClickListener(listOnItemClickListener);
//监听器哪里来?
public ListOnItemClickListener listOnItemClickListener=new ListOnItemClickListener(listview);
//ListOnItemClickListener 的类定义为
public class ListOnItemClickListener implements OnItemClickListener{
private ListView listview;
public ListOnItemClickListener (ListView listview){
this.listview=listview;
}
public void onItemClick(AdapterView<?>adapter,View view,int index,
long arg3){
if(currentListItem!=null){
currentListItem.setBackgroundResource(R.drawable.list_deft_big);
}
currentListItem=view;
currentListItem.setBackgroundResource(R.drawable.list_slct);
setTitle("点击第"+index+"个项目");
//如果你要删除则执行: listview.removeView(view);
//但上面的为子项设背景的代码就要去掉
}
listview.setOnItemClickListener(listOnItemClickListener);
//监听器哪里来?
public ListOnItemClickListener listOnItemClickListener=new ListOnItemClickListener(listview);
//ListOnItemClickListener 的类定义为
public class ListOnItemClickListener implements OnItemClickListener{
private ListView listview;
public ListOnItemClickListener (ListView listview){
this.listview=listview;
}
public void onItemClick(AdapterView<?>adapter,View view,int index,
long arg3){
if(currentListItem!=null){
currentListItem.setBackgroundResource(R.drawable.list_deft_big);
}
currentListItem=view;
currentListItem.setBackgroundResource(R.drawable.list_slct);
setTitle("点击第"+index+"个项目");
//如果你要删除则执行: listview.removeView(view);
//但上面的为子项设背景的代码就要去掉
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询