当前位置: 代码迷 >> Android >> 令人纠结的ExpandableListView的onChildClick事件无法跳转,该如何处理
  详细解决方案

令人纠结的ExpandableListView的onChildClick事件无法跳转,该如何处理

热度:50   发布时间:2016-05-01 21:05:57.0
令人纠结的ExpandableListView的onChildClick事件无法跳转
Java code
 @Override    public boolean onChildClick(ExpandableListView parent, View v,            int groupPosition, int childPosition, long id) {            //do something    //    String pos=parent.getItemAtPosition(childPosition).toString();      // Toast.makeText(Stu80Activity.this,groupPosition+childPosition+"", Toast.LENGTH_LONG).show();         String pos=groupPosition+"-"+childPosition;        String param="";        if(pos.equals("0-0"))        {            param="1";        }        if(pos.equals("0-1"))        {            param="2";        }        if(pos.equals("0-2"))        {            param="3";        }        //        if(pos.equals("1-0"))        {            param="11";        }        if(pos.equals("1-1"))        {            param="4";        }        if(pos.equals("1-2"))        {            param="5";        }        if(pos.equals("1-3"))        {            param="14";        }        if(pos.equals("1-4"))        {            param="6";        }        //        if(pos.equals("2-0"))        {            param="10";        }        //        if(pos.equals("3-0"))        {            param="7";        }        if(pos.equals("3-1"))        {            param="8";        }        if(pos.equals("3-2"))        {            param="9";        }        //        if(pos.equals("4-0"))        {            param="12";        }        if(pos.equals("4-1"))        {            param="13";        }        //        if(pos.equals("5-0"))        {            param="16";        }        if(pos.equals("5-1"))        {            param="17";        }        if(pos.equals("5-2"))        {            param="18";        }        //        if(pos.equals("6-0"))        {            param="19";        }        if(pos.equals("6-1"))        {            param="20";        }        //        if(pos.equals("7-0"))        {            param="23";        }        if(pos.equals("7-1"))        {            param="24";        }        if(pos.equals("7-2"))        {            param="25";        }if(pos.equals("7-3"))        {            param="26";        }        if(pos.equals("7-4"))        {            param="27";        }        if(pos.equals("7-5"))        {            param="28";        }        //        if(pos.equals("8-0"))        {            param="21";        }        if(pos.equals("8-1"))        {            param="15";        }        //Toast.makeText(Stu80Activity.this,param, Toast.LENGTH_LONG).show();                 /*Intent intent=new Intent();        intent.setClass(Stu80Activity.this,list.class);        Bundle bundle=new Bundle();        bundle.putString("param", param);        intent.putExtras(bundle);        startActivity(intent);*/                Intent intent = new Intent(Stu80Activity.this,list.class);        startActivity(intent);                return false;       // return super.onChildClick(parent, v, groupPosition, childPosition, id);    }



试过了n种方法了,,还是立刻报错,,把intent去掉就没问题,,一家上就错了,,什么原因啊,,怎么改

------解决方案--------------------
恭喜楼主犯了不会再犯的错误