当我从另一个不是Activity的Class中调用Dialog时,我想在解除Dialog后取消调用Listview的调用Activity和NotifyDatasetChange适配器。
public class SingleAudioBook extends Activity {
private ListView lv;
public void onCreate(Bundle savedInstanceState) {
lv = (ListView) findViewById(R.id.lvSingleSong);
lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
MyDialog.callLoginDialog(SingleAudioBook.this);
}}}
我的对话框是:
public class MyDialog {
private static Dialog myDialog;
public static void callLoginDialog(final Context c){
...
}
答案 0 :(得分:0)
您可以使用listView和Adapter的静态引用。用以下内容替换您的声明 -
Your_Activity -
public static BaseAdapter your_adapter_name;
public static ListView your_lv_name;
在另一个班级使用 -
// refresh listview
if( Your_Activity.your_lv_name!=null && Your_Activity.your_adapter_name!=null )
{
Your_Activity.your_adapter_name.notifyDataSetChanged();
Your_Activity.your_lv_name.refreshDrawableState();
Your_Activity.your_lv_name.invalidateViews();
}