|
178
|
| tomash · 技术社区 · 16 年前 |
|
|
1
112
I had the same issue.
I was adding items to my
Solution: I have done both,
|
|
|
2
26
I had the same problem, but I fixed it using the method
从班里
|
|
3
20
这是一个 多线程 正确发放和使用 同步的 Blocks This can be prevented. Without putting extra things on UI Thread and causing loss of responsiveness of app. I also faced the same. And as the most accepted answer suggests making change to adapter data from UI Thread can solve the issue. That will work but is a quick and easy solution but not the best one. As you can see for a normal case. Updating data adapter from background thread and calling notifyDataSetChanged in UI thread works. This illegalStateException arises when a ui thread is updating the view and another background thread changes the data again. That moment causes this issue. So if you will synchronize all the code which is changing the adapter data and making notifydatasetchange call. This issue should be gone. As gone for me and i am still updating the data from background thread. Here is my case specific code for others to refer. My loader on the main screen loads the phone book contacts into my data sources in the background.
This PhoneBookManager.getPhoneBookContacts reads contact from phonebook and fills them in the hashmaps. Which is directly usable for List Adapters to draw list. There is a button on my screen. That opens a activity where these phone numbers are listed. 如果在前一个线程完成它的工作之前直接将适配器设置在列表上,那么快速的NaviaGeSE案例就更少发生。它会弹出异常,这就是这个问题的标题。所以我必须在第二个活动中这样做。
Then it creates the adapter and deliver it to the activity where on ui thread i call setAdapter. That solved my issue. This code is a snippet only. You need to change it to compile well for you.
希望这有帮助 |
|
|
4
15
我通过2个列表来解决这个问题。一个列表,我只使用适配器,我做的所有数据更改/更新其他列表。这允许我在后台线程中对一个列表进行更新,然后更新主/UI线程中的“适配器”列表:
|
|
|
5
7
I wrote this code and had it run in a 2.1 emulator image for ~12 hours and did not get the IllegalStateException. I'm going to give the android framework the benefit of the doubt on this one and say that it is most likely an error in your code. I hope this helps. Maybe you can adapt it to your list and data.
|
|
|
6
3
Had this happen intermittently, turns out I only had this issue when the list was scrolled after a 'load more' last item was clicked. If the list wasn't scrolled, everything worked fine. 经过多次调试,我觉得这是个错误,但Android代码中也有不一致之处。 When the validation happens, this code is executed in ListView
But when onChange happens it fires this code in AdapterView (parent of ListView)
Notice the way the Adapter is NOT guaranteed to be the Same!
I only did this because the docs make it seem like it's ok to do ListView.getAdapter javadoc
|
|
|
7
3
我的问题与使用A有关。 Filter together with the ListView. When setting or updating the underlying data model of the ListView, I was doing something like this:
打电话
The problem is that the filtering is done asynchronously, and thus between the end of the
The actual fix is easy, just call
|
|
|
8
3
如果有进给对象,我有一个列表。
它是从没有UI线程追加和截断的。
It works fine with adapter below.
我打电话
|
|
|
9
3
几天前,我遇到了同样的问题,每天造成数千次崩溃,大约0.1%的用户遇到了这种情况。我试过
And I finally solved it. 什么都没有
Finally I found the reason is I used a
我又犯了一个错误
所以解决方案很简单,当我的处理程序触发适配器获取数据和调用时,我只需将数据从数据源复制到适配器。
|
|
|
10
2
我正面临着同样的问题与完全相同的错误日志。
以我为例
这项功能很好,看起来非常令人上瘾,但不幸的是,经常触摸所显示的列表项可能会使其崩溃。
我想,即使您只是在UI线程上工作,适配器也不会在不调用的情况下接受对其数据的许多更改。
|
|
|
11
2
这是Android 4到4.4(KITKAT)中的一个已知bug,并在“& GT;4.4”中得到解决。 请参见这里: https://code.google.com/p/android/issues/detail?id=71936 |
|
|
12
2
即使我在XMPP通知应用程序中遇到了同样的问题,接收器消息也需要重新添加到列表视图中(使用
|
|
|
13
1
I faced a similar problem, here's how I solved in my case. 我验证是否
|
|
|
14
1
我也有同样的问题,我解决了它。我的问题是我用了
|
|
|
15
1
One cause for this crash is that
This fixed the crash for me. |
|
|
16
1
在我的情况下,我称之为方法。
|
|
|
17
0
I was also getting exact same error and using AsyncTask :
我通过
现在我的应用程序工作。 EDIT : In fact, my app still crashed about every 1 in 10 times, giving the same error.
Eventually I came across
我移除了
|
|
|
18
0
请尝试下列解决方案之一:
|
|
|
19
0
hope it helps you |
|
|
20
0
就像@mullins说的那样”
在我的情况下,我有
|
|
|
21
0
我有一个习俗
|
|
22
0
我有同样的情况,我有许多buttongroup把我的项目放在listview上,我在我的项目中改变了一些布尔值,比如holder.rbvar.setonclik… 发生我的问题是因为我在getView()内调用了一个方法;并且在sharePreference内保存了一个对象,所以上面有相同的错误 How I solved it; I removed my method inside getView() to notifyDataSetInvalidated() and problem gone
|
|
|
23
0
i had the same problem. finally i got the solution 在更新ListView之前,如果存在软键盘,请先关闭它。然后设置数据源并调用notifyDataSetChanged()。 当在内部关闭键盘时,listview将更新其用户界面。it keep calling till closing keypad. 这一次,如果数据源发生更改,将引发此异常。 if data is updating in onActivityResult, there is a chance for same error.
|
|
|
24
0
我的解决方案:
1)创建一个
2) do your heavy works (sqlite row fetch , ...) in
3) add all items from temp araylist to your listview's arraylist in
希望这有帮助。 |