开发者

Query regarding handlers in Android

开发者 https://www.devze.com 2023-01-06 23:52 出处:网络
In my application, I have two different activities and both are list activit开发者_如何学运维ies. I use a SimpleAdapter for each activity and each adapter binds to an arraylist during the onCreate. Bo

In my application, I have two different activities and both are list activit开发者_如何学运维ies. I use a SimpleAdapter for each activity and each adapter binds to an arraylist during the onCreate. Both arraylists are present in a different class. Now if there is any change in the arraylists, I have to notify the corresponding activity. I currently made it to work using a public static handler for the activity and calling the handler.sendMessage from the class where arraylists are stored. But I am not very happy with this solution. Is there a better way to do it? Am I missing some Android feature that can easily do this stuff?


You could simply subclass your ListActivity, and define the arraylist on that level, and inherit from your custom ListActivity for those other two classes, and they will use the same arraylist.

0

精彩评论

暂无评论...
验证码 换一张
取 消