如何将数组列表分组为一个

时间:2014-04-19 15:37:01

标签: java android arrays android-arrayadapter

如何将这两个数组列表放入一个数组列表中,以便它仍然可以在我的arrayAdapter中使用。我不记得该怎么做了。

public class MyArrayAdapter extends ArrayAdapter<String>{
        Context context;
        ArrayList<String>mtitle;
        ArrayList<String>mdesc;

        public MyArrayAdapter(Context c, ArrayList<String>title, ArrayList<String>desc) {
            super(c, R.layout.single_row, R.id.viewtitle, title);

...

1 个答案:

答案 0 :(得分:0)

使用java bean类型arraylist。 如: -

public class JBContacts {
    public String strID = "";
    public String strTitle = "";
    public String getStrID() {
        return strID;
    }
    public void setStrID(String strID) {
        this.strID = strID;
    }
    public String getStrTitle() {
        return strTitle;
    }
    public void setStrTitle(String strTitle) {
        this.strTitle = strTitle;
    }

}

ArrayList<JBContacts> mArrayListContacts;
JBContacts mJbContacts;

mArrayListContacts = new ArrayList<JBContacts>();
                mJbContacts = new JBContacts();

                        strId = mJsonObjectContacts.getString(Constants.TAG_ID);
                        strTitle = mJsonObjectContacts
                                .getString(Constants.TAG_TITLE);
                        mJbContacts.setStrTitle(strTitle);