android - Android中的适配器应该是静态内部类还是非静态内部类

标签 android adapter weak-references

我在 Activity 中有一个 ListView,我正在为 ListView 设置自定义适配器。

我的适配器类应该是:

private static class MyAdapter extends ArrayAdapter 

private class MyAdapter extends ArrayAdapter

我想只要适配器包含在 Activity 引用中就没有区别,但我想确认这一点。

最佳答案

如果您谨慎使用适配器,则在适配器内保持上下文很好。适配器通常与它们的上下文(一个 Activity )的生命周期相关联,所以这很好。仅在有意义时才使用 Wea​​kReference。

关于android - Android中的适配器应该是静态内部类还是非静态内部类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7924834/

相关文章:

android - 列表适配器中的复选框行为异常

android - Adwhirl 是否支持 Android 平台上的 Smaato?

c# - 弱引用的线程安全

java - 我可以/应该在 db4o 的复杂对象结构中使用 Wea​​kReference 吗?

android - 在 TableRow 中创建具有相同宽度的 TextView

android - Cordova Android 不会显示 StatusBar

android - 如何将获取的数据转换为产品列表?

ios - 作为iVar的weakSelf

android - React Native Navigation Drawer 重叠状态栏

android - 当移动设备在 Android 中进入休眠模式时服务停止