可扩展的listview子项不显示整个文本。+ android

时间:2011-11-21 06:35:53

标签: android expandablelistview

我正在使用可扩展的列表视图。代码如下,它工作正常。但问题出在一个小组的孩子,我想提供一些重要的信息,但它没有显示出来。它只是显示1行。

public class list1 extends ExpandableListActivity {
private static final String NAME = "name";
   private static final String time = "time";

private static final String IS_EVEN = "IS_EVEN";

private ExpandableListAdapter mAdapter;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    List<Map<String, String>> groupData = new ArrayList<Map<String, String>>();
    List<List<Map<String, String>>> childData = new ArrayList<List<Map<String, String>>>();

        final HashMap<String, String> info1 = new HashMap<String, String>(); 
        info1.put(NAME, "information");
         groupData.add(info1);

        final HashMap<String, String> tt = new HashMap<String, String>(); 
        tt.put(NAME, "time");
        groupData.add(tt);
        final HashMap<String, String> loc = new HashMap<String, String>(); 
        loc.put(NAME, "Location");
        groupData.add(loc);

        List<Map<String, String>> childreninfo = new ArrayList<Map<String, String>>();
        List<Map<String, String>> childrentime = new ArrayList<Map<String, String>>();
        List<Map<String, String>> childrenloc = new ArrayList<Map<String, String>>();

            Map<String, String> infochild = new HashMap<String, String>();
            childreninfo.add(infochild);
            infochild.put(NAME, "asnflabfbalv j;ajf;adf ;j; asjfsap sdjosdjosjdos dosjdosjdosjdos osfjsodfjsofjso osjfosjdfosjf s jsofjsojdsod jdosjdsosod jdsofjsojdfsofd jfosjdfsofjsof odjfsojfsodjosdjsod sojdosjdso djosjdosjds djsodj");

            Map<String, String> timechild = new HashMap<String, String>();
            childrentime.add(timechild);
            timechild.put(NAME, "Childtime " + 1);

            Map<String, String> locchild = new HashMap<String, String>();
            childrenloc.add(locchild);
            locchild.put(NAME, "Childloc " + 1);

        childData.add(childreninfo);
        childData.add(childrentime);
        childData.add(childrenloc);



    // Set up our adapter
    mAdapter = new SimpleExpandableListAdapter(
            this,
            groupData,
            android.R.layout.simple_expandable_list_item_1,
            new String[] { NAME,time },
            new int[] { android.R.id.text1, android.R.id.text2 },
            childData,
            android.R.layout.simple_expandable_list_item_2,
            new String[] { NAME, IS_EVEN }, 
            new int[] { android.R.id.text1, android.R.id.text2 }
            );
    setListAdapter(mAdapter);
  }
}

在这个infochild.put();中它提供了非常大的信息,但这里仅显示第一行信息。

如何修复此问题以显示所有信息?

1 个答案:

答案 0 :(得分:0)

这是因为android.R.layout.simple_expandable_list_item_2定义了TwoLineListItem

您应该使用单个TextView提供简单的布局:

<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/text"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    ...
/>

或者您也可以尝试使用android.R.layout.simple_expandable_list_item_1