简体   繁体   English

android listview适配器组合了两个数组

[英]android listview adapter combine two arrays

I'm wornig sqllite.i have some tables and i select name for example Customer Table and Price from AnotherTable. 我是wearig sqllite.i有一些表,我选择名称,例如来自AnotherTable的客户表和价格。 and i received two array list .first name's array list and secods price's array list. 我收到了两个数组列表.first name的数组列表和secods price的数组列表。 this is a my source 这是我的来源

private ArrayList<GetDictioanyClassByPosition> GetPKFromTable() {
    price_array.clear();
    ArrayList<GetDictioanyClassByPosition> my_list = d_Helper
            .getAllPriceByPosition(0);
    for (int i = 0; i < my_list.size(); i++) {
        String AllPrice = my_list.get(i).getDictionaryPrice();
        GetDictioanyClassByPosition cnt = new GetDictioanyClassByPosition();
        System.err.println(AllPrice + "AllPrice");
        cnt.setDictionaryPrice(AllPrice);
        price_array.add(cnt);
    }
    return price_array;
}

this is a method to check price's array list and this method check name's array list 这是一种检查价格数组列表的方法,此方法检查名称的数组列表

public void AllInfoFromLoanAnalysis() {

    name_list.clear();

    ArrayList<GetAllDictionariesClass> contact_array_from_db = d_Helper
            .getAllInformationFromLoanAnalysis_Table(1, 1);

    Log.e("Sizee", contact_array_from_db.size() + "sizee");
    for (int i = 0; i < contact_array_from_db.size(); i++) {
        int DictionaryID = contact_array_from_db.get(i).getDictionaryID();

        System.out.println(DictionaryID + "DictionaryID");

        GetDictioanyClassByPosition object = new GetDictioanyClassByPosition();
        String name = null ;

        ArrayList<GetDictioanyClassByPosition> DictionaryIdList = d_Helper
                .GetDictionaryIdList(DictionaryID);

        System.out.println(DictionaryIdList.size() + "DictionaryIdList");
        Log.e("Sizee2", DictionaryIdList.size() + "sizee2");

        for (int j = 0; j < DictionaryIdList.size(); j++) {
            name= DictionaryIdList.get(j).getDictionaryName();


            Log.e("object", name + "object");
            object.setDictionaryName(name);


            name_list.add(object);
        }

        for (int j = 0; j < price_array.size(); j++) {

            String AllPrice = price_array.get(i).getDictionaryPrice();
            object.setDictionaryPrice(AllPrice);
            object.setDictionaryName(name);
            price_array.add(object);
        }
        agroproductslistview.setAdapter(agroproduct_adapter);

    }
}

and i called my BaseAdapter Like this 我打电话给我的BaseAdapter就像这样

_adapter = new LoanProductAdapter(
            getApplicationContext(), R.layout.productlistadapter,
            name_list);





public class GetDictioanyClassByPosition {
private String  DictionaryName;
private String DictionaryPrice;


public String getDictionaryName() {
    return DictionaryName;
}

public void setDictionaryName(String DictionaryName) {
    this.DictionaryName = DictionaryName;
}



public String getDictionaryPrice() {
    return DictionaryPrice;
}

public void setDictionaryPrice(String DictionaryPrice) {
    this.DictionaryPrice = DictionaryPrice;
}

} }

i can selected and show my prices and names in different array list but i want to marge both array list and would adapter in my list view .how i can solve my problem? 我可以选择并在不同的数组列表中显示我的价格和名称,但我想要列出两个数组列表,并在我的列表视图中适应。我可以解决我的问题吗? if anyone knows solution please help me thanks 如果有人知道解决方案,请帮助我谢谢

Please refer below example. 请参考以下示例。

public ArrayList<customObject> _historyArrayList = new ArrayList<customObject>();
    public ArrayList<customObject> _completedArraylist = new ArrayList<customObject>();

For merging simply use: 合并只需使用:

 _historyArrayList.addAll(_completedArraylist);

Note: Make sure your customObject are same 注意:确保您的customObject相同

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

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