程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> 編程綜合問答 >> android-expandablelistview中自定義的child無法點擊

android-expandablelistview中自定義的child無法點擊

編輯:編程綜合問答
expandablelistview中自定義的child無法點擊

寫了一個自定義的expandablelistview
group設置監聽事件,能被點擊
child setOnChildClickListener()無反應 什麼原因???

下面是適配器中getchildView()的函數
試了一下 把return換成title(title是自定義布局中的一個textview) 可以進行點擊
怎麼回事????

        public View getChildView(int groupPosition, int childPosition,
                boolean isLastChild, View convertView, ViewGroup parent) {
            View view = convertView;
            if (view == null) {
                //LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                LayoutInflater inflater = LayoutInflater.from(getActivity());
                view = inflater.inflate(R.layout.childitem, null);
            }
            final TextView title = (TextView) view
                    .findViewById(R.id.child_text);
            title.setText(childData.get(groupPosition).get(childPosition)
                    .get("child_text1").toString());
            final TextView title2 = (TextView) view
                    .findViewById(R.id.child_text2);
            title2.setText(childData.get(groupPosition).get(childPosition)
                    .get("child_text2").toString());
            final TextView title3 = (TextView) view
                    .findViewById(R.id.child_text3);
            title3.setText(childData.get(groupPosition).get(childPosition)
                    .get("child_text3").toString());            
            return view;
        }

isChildSelectable()函數已設為true

         public boolean isChildSelectable(int groupPosition, int childPosition) {
            return true;
        }

最佳回答:


單從上述代碼來看,沒什麼大問題,如果點擊不了,可能是你的childitem裡有需要獲取焦點的控件。你試著在getChildView裡把整個view設置上onclick監聽,看看能不能監聽到

sinat_24946363
  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved