简体   繁体   English

使用SQLite显示ListView

[英]Displaying a ListView using SQLite

A part of the project I'm working on is searching about places in a database. 我正在研究的项目的一部分是搜索数据库中的位置。 The user first chooses a category, then the search criteria and the results should be displayed in a list view in which the items are from the database. 用户首先选择一个类别,然后搜索条件和结果应显示在列表视图中,其中的项来自数据库。 Only one works right and the rest don't, even though they have similar code. 即使它们有相似的代码,也只有一种能正确运行,而其余的则行不通。

The first search category is Hotel s which works perfectly fine, the rest of the categories are not working properly, the methods are correct but displaying the data is wrong, instead of displaying the name it displays packageName.tableName@weirdNumber example( egypt.database.NileCruise@44f40448 ). 第一个搜索类别是Hotel ,它运行良好,其余类别均无法正常工作,方法正确,但是显示数据错误,而不是显示名称,而是显示packageName.tableName@weirdNumber示例(例如egypt.database.NileCruise@44f40448 )。

By default ArrayAdapter will call the method toString on your object to get a String to show in the list row. 默认情况下, ArrayAdapter将在对象上调用toString方法以获取要显示在列表行中的String

You probably implemented the method toString for the class Hotel but forgot to implement it for the class NileCruise and you end up with the default implementation of toString (that returns what you currently see). 您可能为Hotel类实现了toString方法,但是却忘记了为NileCruise类实现了该方法,最后得到的是toString的默认实现(返回您当前看到的内容)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM