Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/197.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/visual-studio-2010/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
android中的多级可扩展列表视图_Android_Expandablelistview_Expandablelistadapter - Fatal编程技术网

android中的多级可扩展列表视图

android中的多级可扩展列表视图,android,expandablelistview,expandablelistadapter,Android,Expandablelistview,Expandablelistadapter,我开发了一个可扩展列表视图 我的代码是: public class SingleMenuItemActivity extends ExpandableListActivity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView

我开发了一个
可扩展列表视图

我的代码是:

public class SingleMenuItemActivity extends ExpandableListActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.particular);

    // Construct Expandable List
final String LABEL = "label";
final String VALUE = "value";
final String GROUP1 = "Group1";
final String GROUP2 = "Group1";
    final LayoutInflater layoutInflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    final ArrayList<HashMap<String, String>> headerData = new ArrayList<HashMap<String, String>>();

    final HashMap<String, String> group1 = new HashMap<String, String>();
    group1.put(GROUP1, "OrderInformation");
    headerData.add( group1 );

    final HashMap<String, String> group2 = new HashMap<String, String>();
    group2.put(GROUP2, "CustomerInformation");
    headerData.add( group2);
    final ArrayList<ArrayList<HashMap<String, Object>>> childData = new ArrayList<ArrayList<HashMap<String, Object>>>();

    final ArrayList<HashMap<String, Object>> group1data = new ArrayList<HashMap<String, Object>>();
    childData.add(group1data);

    final ArrayList<HashMap<String, Object>> group2data = new ArrayList<HashMap<String, Object>>();
    childData.add(group2data);

    // Set up some sample data in both groups
    for( int i=0; i<1; ++i) {
        final HashMap<String, Object> map = new HashMap<String,Object>();
        String s= getIntent().getStringExtra("payment_method");
        String s1= getIntent().getStringExtra("subtotal");
      map.put(LABEL, "Payment Method:");
        map.put(VALUE, s);
       group1data.add(map);
      final HashMap<String, Object> map1 = new HashMap<String, Object>();
    map1.put(LABEL, "Subtotal:");
    map1.put(VALUE, s1);
    group1data.add(map1);
      }
    final HashMap<String, Object> map = new HashMap<String, Object>();
    String s3= getIntent().getStringExtra("firstname");
    String s4= getIntent().getStringExtra("lastname");
    String s1= getIntent().getStringExtra("phone");
    String s2= getIntent().getStringExtra("url");
    map.put(LABEL, "Firstname::");
    map.put(VALUE, s3);
    group2data.add(map);


    // Create new map for second row
    // You should use loop to do this
    // insert new values and add to group row
    final HashMap<String, Object> map1 = new HashMap<String, Object>();
    map1.put(LABEL, "Lastname:");
    map1.put(VALUE, s4);
          group2data.add(map1);
        final HashMap<String, Object> map2 = new HashMap<String, Object>();
    map2.put(LABEL, "URL:");
    map2.put(VALUE, s1);
    group2data.add(map2);
    final HashMap<String, Object> map3 = new HashMap<String, Object>();
    map3.put(LABEL, "Phone:");
    map3.put(VALUE, s2);
    group2data.add(map3);
     setListAdapter(new SimpleExpandableListAdapter(this, headerData,
            R.layout.group_row, new String[] { GROUP1, GROUP2 }, // the names
                                                                // of the
                                                                // data
            new int[] { R.id.order }, // the text field to populate with the
                                        // field data
            childData, 0, null, new int[] {}) {
        @Override
        public View getChildView(int groupPosition, int childPosition,
                boolean isLastChild, View convertView, ViewGroup parent) {
            final View v = super.getChildView(groupPosition, childPosition,
                    isLastChild, convertView, parent);



            // Populate your custom view here
            ((TextView) v.findViewById(R.id.label))
            .setText((String) ((Map<String, Object>) getChild(
                    groupPosition, childPosition)).get(LABEL));

            ((TextView) v.findViewById(R.id.value))
                    .setText((String) ((Map<String, Object>) getChild(
                            groupPosition, childPosition)).get(VALUE));

            return v;
        }

        @Override
        public View newChildView(boolean isLastChild, ViewGroup parent) {

            return layoutInflater.inflate(
                    R.layout.expandable_list_item_with_image, null, false);

        }
    });
    ExpandableListView list = (ExpandableListView) findViewById(android.R.id.list);
    list.setOnChildClickListener(new OnChildClickListener() {
        public boolean onChildClick(ExpandableListView parent, View v,
                int groupPosition, int childPosition, long id) {
            System.out.println("Group:" + groupPosition + ", Child: "
                    + childPosition);
            return true;
        }
    });

}

     }
但我希望需要的格式是:

-->Orderinformation
          * payment_method
          * subtotal
--->Customerinformation
        -->personalinformation
                *firstname
                *lastname
        -->Contactinformation
                *phone
                *url

如何在此使用
HashMap
并在另一个
ExpandableListView
中创建
ExpandableListView
。请给我一些解决方案。

我认为您需要嵌套的listview。是,我希望需要嵌套的expandablelistview。请参考我的代码一次,并给我使用hashmap在另一个组中创建组的解决方案。我认为您需要嵌套的listview。是的,我希望需要嵌套的expandablelistview。请参考我的代码一次,并给出使用hashmap在另一个组中创建组的解决方案。
-->Orderinformation
          * payment_method
          * subtotal
--->Customerinformation
        -->personalinformation
                *firstname
                *lastname
        -->Contactinformation
                *phone
                *url