android expandablelistview二级目录点击跳转另一个activity

比如点击“妹妹”跳转一个新的聊天界面package com.czu.chat;

import android.app.ExpandableListActivity;

import android.content.Context;

import android.content.Intent;

import android.os.Bundle;

import android.os.Handler;

import android.os.Message;

import android.view.LayoutInflater;

import android.view.View;

import android.view.ViewGroup;

import android.widget.BaseExpandableListAdapter;

import android.widget.Button;

import android.widget.ExpandableListView;

import android.widget.LinearLayout;

import android.widget.SimpleExpandableListAdapter;

import android.widget.TextView;

import java.util.ArrayList;

import java.util.HashMap;

import java.util.List;

import java.util.Map;

/**

  • Created by 布丁 on 2016/5/30.

    /

    public class ExpandActivity extends ExpandableListActivity {

    /
    * Called when the activity is first created. */

    @Override

    public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    setContentView(R.layout.two);

    //创建二个一级条目标题                                                                                         
    Map<String, String> title_1 = new HashMap<String, String>();                                         
    Map<String, String> title_2 = new HashMap<String, String>();                                         
    
    title_1.put("group", "家人");                                                                          
    title_2.put("group", "宠物");                                                                          
    
    //创建一级条目容器                                                                                           
    List<Map<String, String>> gruops = new ArrayList<Map<String, String>>();                             
    
    gruops.add(title_1);                                                                                 
    gruops.add(title_2);                                                                                 
    
    //创建二级条目内容                                                                                           
    
    //内容一                                                                                                
    Map<String, String> content_1 = new HashMap<String, String>();                                       
    Map<String, String> content_2 = new HashMap<String, String>();                                       
    
    content_1.put("child", "姐姐");                                                                        
    content_2.put("child", "妹妹");                                                                        
    
    List<Map<String, String>> childs_1 = new ArrayList<Map<String, String>>();                           
    childs_1.add(content_1);                                                                             
    childs_1.add(content_2);                                                                             
    
    //内容二                                                                                                
    Map<String, String> content_3 = new HashMap<String, String>();                                       
    Map<String, String> content_4 = new HashMap<String, String>();                                       
    
    content_3.put("child", "猫咪");                                                                        
    content_4.put("child", "汪汪");                                                                        
    
    List<Map<String, String>> childs_2 = new ArrayList<Map<String, String>>();                           
    childs_2.add(content_3);                                                                             
    childs_2.add(content_4);                                                                             
    
    //存放两个内容, 以便显示在列表中                                                                                   
    List<List<Map<String, String>>> childs = new ArrayList<List<Map<String, String>>>();                 
    childs.add(childs_1);                                                                                
    childs.add(childs_2);                                                                                
    
    //创建ExpandableList的Adapter容器                                                                         
    //参数: 1.上下文    2.一级集合 3.一级样式文件 4. 一级条目键值  5.一级显示控件名                                                  
    //   6. 二级集合 7. 二级样式 8.二级条目键值 9.二级显示控件名                                                              
    SimpleExpandableListAdapter sela = new SimpleExpandableListAdapter(                                  
            this, gruops, R.layout.groups, new String[]{"group"}, new int[]{R.id.textGroup},             
            childs, R.layout.childs, new String[]{"child"}, new int[]{R.id.textChild}                    
    );                                                                                                   
    
    //加入列表                                                                                               
    setListAdapter(sela);                                                                                
    

    }

http://www.2cto.com/kf/201312/265457.html

既然是点击跳转,你设置好Child的Onclick事件就可以了啊

setonchildrenonclicklistener 好像是这个

@Override
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id)
{
// TODO Auto-generated method stub
return super.onChildClick(parent, v, groupPosition, childPosition, id);
}