如何从适配器或 Android 中的另一个 Activity 刷新列表视图?

How To Refresh Listview From Adapter or Another Activity in Android?

你好,我需要尽快从适配器 class 或另一个 activity.Please 回复刷新我的列表视图。

就这么办

//declare a static variable
public static MyListAdapter adapter;

//at the place where you call the adapter constructor;
MyListAdapter adapter=new MyListAdapter(//parameters here);
MyListAdapter=adapter;

//call from anywhere
try{
  ClassName.adapter.notifyDatasetChanged();
}catch(Throwable e){
  //error occured. Probably null
}

每当修改相应的数据集时,只需在您的 Adapter 上调用 notifyDataSetChanged()

您可以通过在放置列表视图的地方创建 activity 的静态引用并调用 referesh 函数来实现,之后只需在 Adapter 或任何其他 class 中调用该函数即可引用那个 class 的那个静态变量。 例如:Classname.stataticvar.fucntion

试试吧。