问题
I'm using a TouchListView
by CommonWare and so far it's working fine, But it fails in the following case:
activity A
has a TouchListView and button to add an item , now when i click over a button,activity B
opens up and once the user choose the item i am callingfinish
to endactivity B
- and it comes back to
activity A
.
Now here drag n drop in TouchListView
doesn't work I mean items are getting dragged but not able to be placed where a user wants, I tried a lot but could not find a way to fix it.
回答1:
I suspect you're doing some setup in onCreate() that's not getting called when you return to Activity A because you're entering it the 2nd (and subsequent) time(s) via onResume().
http://developer.android.com/reference/android/app/Activity.html
BaseAdapter adapter;
List<myStuff> stuffs;
if (adapter == null) {
adapter = new BaseAdapter()
if (stuffs == null) {
stuffs = new List<myStuff>();
}
}
You're going to need to do something like that and add List to your savedInstanceState bundle in onSaveInstanceState() then dig it out when the activity restarts.
来源:https://stackoverflow.com/questions/15719106/touchlistview-is-not-working-when-parent-activity-finishes