【问题标题】:Database and listview error [closed]数据库和列表视图错误[关闭]
【发布时间】:2016-03-27 15:16:51
【问题描述】:

我遇到了自定义列表视图的问题。我收到了这个错误 " 在 com.example.azat_pc.nekadarkaldi.EventsActivity$myAdapter.getView(EventsActivity.java:78) " 这是我的项目; https://github.com/azatgoktas/nekadarkaldi 那么这件事有什么问题呢?

【问题讨论】:

  • 请具体说明您遇到的确切错误。如果。你可以发布错误
  • 在此处添加您的代码,以便查看而不是人们来回导航

标签: android database listview


【解决方案1】:

我通过进行以下更改解决了这个问题: Click here Download the project-after-changes

EventsActivity 类中

改变

 public myAdapter(Context context, int resource, List<Events> objects, Activity activity) {

  public myAdapter(Activity activity, int resource, List<Events> objects) {

改变

year= (TextView) findViewById(R.id.year);

 year= (TextView) convertView.findViewById(R.id.year);

可以在项目中看到其他变化..

【讨论】:

  • 谢谢:)。我解决了这个问题。但是我为什么要喜欢 year= (TextView) convertView.findViewById(R.id.year);this
  • 不客气,因为 (convertView) 的上下文与应用程序的当前上下文不同,当前上下文无法访问另一个上下文中的控件..
  • 好的,我知道了:)再次感谢您。
【解决方案2】:

尝试更改以下内容

convertView=layoutInflater.inflate(resource,null);

convertView= layoutInflater.inflate(R.layout.yourLayoutId, parent, false);

【讨论】:

  • 我又遇到了同样的错误。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-04-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多