列表视图中的子项不起作用

Sub item in list view doesn't work

我的代码是关于带有子项的列表视图,我用数组字符串 [] 填充它但只显示第一个字符串,有人可以帮我吗?

private String[] d1 = new String[5];

private String[] d2 = new String[5];

ArrayList<HashMap<String, String>> data;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.listview);
listView = (ListView) findViewById(R.id.list);

    for(int i=0;i<lengh;i++){
        Map<String,Object> daat = new HashMap<String, Object>();
        daat.put("title",  d1[i]);
        daat.put("sub", d2[i]);
        data.add(daat);
    }

    SimpleAdapter adapter = new SimpleAdapter(this, data, android.R.layout.simple_list_item_2,
            new String[]{"title", "sub"}, new int[]{android.R.id.text1, android.R.id.text2});

    listView.setAdapter(adapter);
    adapter.notifyDataSetChanged();

my example

 for(int i=0;i<d1.length;i++){
    Map<String,Object> daat = new HashMap<String, Object>();
    daat.put("title",  d1[i]);
    daat.put("sub", d2[i]);
    data.add(daat);
 }

在 for 循环中听到指定字符串长度并尝试我希望它有效。