gpt4 book ai didi

android - 如何在android中显示数据库中的所有行

转载 作者:行者123 更新时间:2023-11-30 02:50:31 34 4
gpt4 key购买 nike

如何在android中显示数据库中的所有行。在下面的代码中它只显示数据库表中的最后一行。请帮助我。

            public void dynamicLayout(String sfixed_AssetDescription ) {


LinearLayout ll=new LinearLayout(this);

View child = getLayoutInflater().inflate(R.layout.fixed_asset_dlayout, null);

TextView dfixed_AssetID = (TextView) child.findViewById(R.id.dfixed_AssetID);
TextView dfixed_AssetDescription = (TextView) child.findViewById(R.id.dfixed_AssetDescription);
TextView dfixed_SuppliersName = (TextView) child.findViewById(R.id.dfixed_SuppliersName);
TextView dfixed_Makemodelotherspec = (TextView) child.findViewById(R.id.dfixed_Makemodelotherspec);
TextView dfixed_PO_no = (TextView) child.findViewById(R.id.dfixed_PO_no);
TextView dfixed_PO_Date = (TextView) child.findViewById(R.id.dfixed_PO_Date);
TextView dfixed_Bill_No = (TextView) child.findViewById(R.id.dfixed_Bill_No);
TextView dfixed_qty = (TextView) child.findViewById(R.id.dfixed_qty);
TextView dfixed_Dateputtouse = (TextView) child.findViewById(R.id.dfixed_Dateputtouse);
TextView dfixed_rateofdescription = (TextView) child.findViewById(R.id.dfixed_rateofdescription);
TextView dfixed_purchasevalue = (TextView) child.findViewById(R.id.dfixed_purchasevalue);
TextView dfixed_salevalue = (TextView) child.findViewById(R.id.dfixed_salevalue);
TextView dfixed_total = (TextView) child.findViewById(R.id.dfixed_total);
Button edit = (Button) child.findViewById(R.id.dfixed_edit);

Button delete = (Button) child.findViewById(R.id.dfixed_delete);
farp=db.getFARDetails();
/*List<String>list=new ArrayList<String>();
for(int i=0;i<farp.size();i++){
//list.add(maap.get(i).getAsset_Name());
farp=db.getFARDetails();
//dfixed_AssetID.setText(farp.get(farp.size()).getAsset_ID());
Log.v("___________________________", "farp.get(i).getAsset_ID()___________"+farp.get(i).getAsset_ID());
// Log.v("___________________________", "farp.get(i).getAsset_ID()___________"+farp);
//dfixed_AssetID.setText(farpojo.getAsset_ID());
//Log.v("___________________________", "farpojo.getAsset_ID()___________"+farpojo.getAsset_ID());

}*/

List<Fixed_asset_register_pojo> f = db.getFARDetails();
//for(int i=0;i<farp.size();i++){
for (Fixed_asset_register_pojo f1 : f) {



dfixed_AssetID.setText(f1.getAsset_ID());
Log.e("LLLLLLLLLLLLLLLLLLLLLLLLLLLL", "FFFFFFFFFFFFFFFFFFFFFFFFFFFFF"+f1.getAsset_ID());
dfixed_AssetDescription.setText(sfixed_AssetDescription);
dfixed_SuppliersName.setText(f1.getSupplier_Name());
dfixed_Makemodelotherspec.setText(f1.getModel_Specifications());
dfixed_PO_no.setText(f1.getPurchase_Order_No());
dfixed_PO_Date.setText(f1.getPurchase_Order_Date());
dfixed_Bill_No.setText(f1.getBill_No());
dfixed_qty.setText(f1.getQuantity());
dfixed_Dateputtouse.setText(f1.getDate_Put_To_Use());
dfixed_rateofdescription.setText(f1.getRate_Of_Depreciation());
dfixed_purchasevalue.setText(f1.getPurchase_Amount());
dfixed_salevalue.setText(f1.getSale_Amount());
dfixed_total.setText(f1.getTotal_Amount());
}

ll.addView(child);
linearLayout.addView(ll);

}

我想显示数据库表中的所有行。但它显示在 logcat 中,在设备中它只显示表中的最后一行。所以请帮助我。![在此处输入图片描述][1]

最佳答案

下面的代码是获取数据库中的所有列表。它适用于我。

          public void dynamicLayout(String sfixed_AssetDescription ) {
List<Fixed_asset_register_pojo> f = db.getFARDetails();
for (Fixed_asset_register_pojo f1 : f) {

View child = getLayoutInflater().inflate(R.layout.fixed_asset_dlayout, null);

TextView dfixed_AssetID = (TextView) child.findViewById(R.id.dfixed_AssetID);
TextView dfixed_AssetDescription = (TextView) child.findViewById(R.id.dfixed_AssetDescription);
TextView dfixed_SuppliersName = (TextView) child.findViewById(R.id.dfixed_SuppliersName);
TextView dfixed_Makemodelotherspec = (TextView) child.findViewById(R.id.dfixed_Makemodelotherspec);
TextView dfixed_PO_no = (TextView) child.findViewById(R.id.dfixed_PO_no);
TextView dfixed_PO_Date = (TextView) child.findViewById(R.id.dfixed_PO_Date);
TextView dfixed_Bill_No = (TextView) child.findViewById(R.id.dfixed_Bill_No);
TextView dfixed_qty = (TextView) child.findViewById(R.id.dfixed_qty);
TextView dfixed_Dateputtouse = (TextView) child.findViewById(R.id.dfixed_Dateputtouse);
TextView dfixed_rateofdescription = (TextView) child.findViewById(R.id.dfixed_rateofdescription);
TextView dfixed_purchasevalue = (TextView) child.findViewById(R.id.dfixed_purchasevalue);
TextView dfixed_salevalue = (TextView) child.findViewById(R.id.dfixed_salevalue);
TextView dfixed_total = (TextView) child.findViewById(R.id.dfixed_total);

Button edit = (Button) child.findViewById(R.id.dfixed_edit);

Button delete = (Button) child.findViewById(R.id.dfixed_delete);

dfixed_AssetID.setText(f1.getAsset_ID());
Log.e("LLLLLLLLLLLLLLLLLLLLLLLLLLLL",
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + f1.getAsset_ID());
dfixed_AssetDescription.setText(sfixed_AssetDescription);
dfixed_SuppliersName.setText(f1.getSupplier_Name());
dfixed_Makemodelotherspec.setText(f1.getModel_Specifications());
dfixed_PO_no.setText(f1.getPurchase_Order_No());
dfixed_PO_Date.setText(f1.getPurchase_Order_Date());
dfixed_Bill_No.setText(f1.getBill_No());
dfixed_qty.setText(f1.getQuantity());
dfixed_Dateputtouse.setText(f1.getDate_Put_To_Use());
dfixed_rateofdescription.setText(f1.getRate_Of_Depreciation());
dfixed_purchasevalue.setText(f1.getPurchase_Amount());
dfixed_salevalue.setText(f1.getSale_Amount());
dfixed_total.setText(f1.getTotal_Amount());
linearLayout.addView(child);
}

关于android - 如何在android中显示数据库中的所有行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24259919/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com