android:如何同时设置Viewgroup及其子视图的侦听器?

android:如何同时设置Viewgroup及其子视图的侦听器?,android,android-listview,android-adapter,Android,Android Listview,Android Adapter,我正在为我的listview使用自定义适配器。代码如下: public class ContentAdapter extends ArrayAdapter<Content>{ private ArrayList<Content> items; public ContentAdapter(Context context, int textViewResourceId, ArrayList<Content> objects) {

我正在为我的listview使用自定义适配器。代码如下:

    public class ContentAdapter extends ArrayAdapter<Content>{

    private ArrayList<Content> items;

    public ContentAdapter(Context context, int textViewResourceId, ArrayList<Content> objects) {
        super(context, textViewResourceId, objects);
        this.items=objects;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View v=convertView;
        if (v==null){
            LayoutInflater inflater=(LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            v=inflater.inflate(R.layout.list_items_layout, null);
        }
        Content content=items.get(position);
        if (content!=null){
            TextView nm=(TextView)v.findViewById(R.id.itemname);
            TextView sm=(TextView)v.findViewById(R.id.itemsubname);
            nm.setTextColor(Color.RED);
            nm.setText(content.getName());
            sm.setTextColor(Color.GRAY);
            sm.setText(content.getSubname());
        }
        return v;
    }
R.layout.列表\项目\布局:

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:descendantFocusability="blocksDescendants">

<TextView android:id="@+id/itemname"
    android:textIsSelectable="true"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text=""
    android:textSize="20sp"/>

<TextView android:id="@+id/itemsubname"
    android:textIsSelectable="true"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text=""
    android:textSize="15sp"/>

当我使用StimoItCurrCistListEnter为ListVIEW创建侦听器时,虽然设置了侦听器,但它只能在单击VIEW组的空白部分时识别。如果我点击这两个文本视图中的任何一个,它都无法响应


是否有任何方法可以设置一个可以同时监视视图组及其子视图的侦听器?

如有任何帮助,将不胜感激!!!我不明白你的问题,如果你想用正常的方式来做,请记住这个android:DegenantFocusability=BlocksDescenedant如果我删除android:DegenantFocusability,监听器将完全停止响应…你可以在适配器的getView方法中,在你想要点击的文本视图上设置onClickListener。