【发布时间】:2014-08-08 13:27:48
【问题描述】:
我在 Android 中有两个数据库 .sqlite。
productosdb.sqlite 和 entradas.sqlite 各有一个表。
在 productosdb 我有表 "entradas"={id,cod1,cod2,descrip,present,pale} 和另一个 "entradas"={id,idref(that is cod1 already saved from the other table),cant,vto}
我想显示表 "entradas" 的所有项目,但给适配器一个包含两个表的所有字段的列表。当我从表"entradas" 中得到一行时,我收到消息idrefto search the other the missing fields。有些东西不工作。以下是部分代码:
private List<ProductoSUMADO> listasumada = new LinkedList<ProductoSUMADO>();
Producto temporalProducto = new Producto();
List<ProductoConVencimiento> temporalEntrada = new LinkedList<ProductoConVencimiento>();
String asd = bundle.getString("codigo");
temporalProducto = managerdb.getProductoPorCodigoBarras(asd);
String sss = temporalProducto.getCodprod();
temporalEntrada = db.getProductosPorIDRef(sss);
for (int pos = 0; pos < temporalEntrada.size(); pos++)
{
ProductoSUMADO p = new ProductoSUMADO(temporalProducto.getCodbar()),
temporalProducto.getCodprod(),
temporalProducto.getDescrip(),
temporalProducto.getPresent(),
temporalProducto.getPale(),
temporalEntrada.get(pos).getCant(),
temporalEntrada.get(pos).getVto(),
temporalEntrada.get(pos).getNotas());
listasumada.add(p);
}
CustomAdapter2 adapter = new CustomAdapter2(this, listasumada);
listview.setAdapter(adapter);
也许你明白我想做什么并展示另一种方法。
【问题讨论】:
-
我认为对于您的情况,仅发布此代码 sn-p 是不够的。有很多地方做错了。
标签: android database list sqlite listview