相关疑难解决方法(0)

Android:notifyDataSetChanged(); 不工作

我在服务器和数据库中有一个数据库,我从数据库中的一个表中获取一些值.我将这些信息正确地加载到列表中,但我想知道为什么当有变化时,即使我使用也没有任何反应notifyDataSetChanged();.我必须说,为了加载加载数据y使用AsyncTaskClass所以,我的问题是我不知道是否使用notifyDataSetChanged(); 方法正确,因为如果有变化我想刷新图像.以下是该类代码的一部分:

@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.all_candidatos);


        candidatosList = new ArrayList<HashMap<String, String>>();

        new CargarCandidatos().execute();
    }


//  public void timer(){
//       new CountDownTimer(tiempo, 100) {
//
//              public void onTick(long millisUntilFinished) {
//                  
//              }
//
//              public void onFinish() {
//              //  new CargarCandidatos().execute();
//
//              }
//           }.start();}



    /**
     * Background Async Task to Load all product by making HTTP Request
     * */
    class CargarCandidatos extends AsyncTask<String, String, String> {

        /**
         * Before starting …
Run Code Online (Sandbox Code Playgroud)

android refresh adapter

19
推荐指数
3
解决办法
6万
查看次数

Android - setListAdapter()+ notifyDataSetChanged()澄清

ListFragment的数据由自定义适配器(SimpleAdapter在我的情况下)填充.我notifyDataSetChanged()在课堂上使用扩展时遇到了问题ListFragment.经过大量的浏览和之后的几个(有用的)Stack Overflow帖子:

listview没有使用notifydatasetchanged()调用进行更新

在notifyDataSetChanged之后Android ListView没有刷新

适配器notifyDataSetChanged不起作用

notifyDataSetChanged不起作用

从BaseAdapter调用notifyDataSetChanged时,ListView不会更新

我知道松散(并且非常不推荐)的解决方法是使用重新设置适配器setListAdapter().但是我现在也面临着这个问题.

文档http://developer.android.com/reference/android/app/ListFragment.html#setListAdapter(android.widget.ListAdapter)提到了setListAdapter()

提供列表视图的光标.

但我还是有一些问题.

Q1.使用setListAdapter()"指向"同一适配器实例多次初始化适配器?

Q2.当使用setListAdapter()多次设置适配器时,调用getListAdapter()然后调用notifyDataSetChanged()时会发生什么?

Q3.这个问题基于Q2的假设 - 当notifyDataSetChanged()多次设置适配器时调用,哪些适配器实例(这部分是假设),如果它们存在'实际上是通知变更?

我是Android的初学者,我相信有一些我不理解的细微差别.如果你能澄清这些问题,我将非常感激.也非常感谢你的时间.

android android-listview android-adapter

5
推荐指数
1
解决办法
618
查看次数