本帖最后由 guolucky2003 于 2013-06-22 15:10:26 编辑

解决方案 »

  1.   

    View v = mScrollTypeLayout.getChildAt(0);
    for(int i = 0; i < v.getChildCount();i++) {
       View vv = v.getChildAt(i);
        vv.setOnClickL..(new Cl.///() {
                public void click(View view) {
                       id= vv.getId();
                }
       })
    }
    你试试
      

  2.   

    也可以在ScrollTypeLayout加一个变量OnclickListener ,设置setter方法
    然后把MainActivity的监听传过去
      

  3.   


    View没有getChildCount()属性,但mScrollTypeLayout.getChildCount();因为我在HorizontalScrollView下还加了LinearLayout,所以我这样写:mScrollTypeLayout = (ScrollTypeLayout)findViewById(R.id.article_type_layout);
    LinearLayout mLinearLayout = (LinearLayout)mScrollTypeLayout.getChildAt(0);
    for(int i = 0; i < mLinearLayout.getChildCount(); i++)
    {
    View child = mLinearLayout.getChildAt(i);
    child.setOnClickListener(this);
    }但还是不行,LinearLayout下面已经是我想要的TextView,但是mLinearLayout.getChildCount为0
      

  4.   

    原来是因为我在子线程完成时再填TextView,所以主线程找不到,但现在又发现新问题,就是自定义控件没有执行Onclick事件,而调用他的Activiy可以触发了,不是可以两个都触发吗?
    所以结贴了,再开一个来问.
      

  5.   

    这里有DEMO,可以参考http://download.csdn.net/detail/llfnqt/8268733