android可扩展列表需要帮助

时间:2011-06-01 10:34:06

标签: android position expandablelistview

public boolean onChildClick(ExpandableListView parent, View v,
        int groupPosition, int childPosition, long id) {
    Log.d(LOG_TAG, "onChildClick: " + childPosition);

    Button btnPlay=(Button)v.findViewById(R.id.Play);
    Button btnDelete=(Button)v.findViewById(R.id.Delete);
    Button btnEmail=(Button)v.findViewById(R.id.Email);
    btnPlay.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            Toast.makeText(FindFilesByType.this, "u clicked play btn", Toast.LENGTH_LONG).show();               
        }
    });
in to above code i've made expandable list into that first i've put some content and if it expand,it displays 3 button.. 
PLAY,EMAIL and DELETE my problem is that it doesn't react on button click event what is i am missing? thank in advance -pragna

1 个答案:

答案 0 :(得分:3)

嗯,我想,你应该在覆盖onClick

的同时实施Button getChildView()
public View getChildView(int groupPosition, int childPosition, boolean isLastChild,
                   View convertView, ViewGroup parent) {
        LinearLayout v = (LinearLayout) LayoutInflater.from(FindFilesByType.this).inflate(R.layout.row, null) ; //we assume your layout file name is row.xml
        Button btnPlay=(Button)v.findViewById(R.id.Play);
        Button btnDelete=(Button)v.findViewById(R.id.Delete);
        Button btnEmail=(Button)v.findViewById(R.id.Email);
        btnPlay.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View arg0) {
                // TODO Auto-generated method stub
                Toast.makeText(FindFilesByType.this, "u clicked play btn", Toast.LENGTH_LONG).show();               
            }
        }); 
        return v;


}