关于ArrayAdapter两个构造函数的区别

关于ArrayAdapter两个构造函数的区别

public ArrayAdapter (Context context, int resource, int textViewResourceId, List objects)

与这个

public ArrayAdapter (Context context, int resource, List objects)

其中resource 与textViewResourceId有什么区别

官方文档解释如下

resource The resource ID for a layout file containing a layout to use when instantiating views.

textViewResourceId The id of the TextView within the layout resource to be populated

没怎么理解是因为我自己定义了一个含有imageview的视图,不知道该用哪个构造函数

阅读 3.9k
1 个回答

resource是layout,textViewResourceId是textview的id,如果用了自定义的textview要把这个id传过去,要么就必须把textview的id设为@android:id/textview,大概是这样

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题