我有一个列表视图,工作良好,涟漪效果工作在列表项按。但我已经添加并使用slide expandable list view 库来增加listvview的功能。一切正常,但添加库后,项目单击上的涟漪不起作用
我的列表适配器的getview()

public View getView(final int position, View view, ViewGroup parent)
{
    final ViewHolder holder;
    if(view == null){
        holder = new ViewHolder();
        view = inflater.inflate(R.layout.testlistitem,null);
        holder.listHeading = (TextView) view.findViewById(R.id.beg_list_itemTextView);

        holder.listHash = (TextView) view.findViewById(R.id.listview_hashtags);
        holder.alphabetList = (ImageView) view.findViewById(R.id.beg_list_itemImageView);

        holder.favariteImage = (ImageView) view.findViewById(R.id.favbtn);

        view.setTag(holder);

    }else{
        holder = (ViewHolder) view.getTag();
    }
    CodeList codes = (CodeList) getItem(position);
    holder.listHeading.setText(codeList.get(position).getListHeading());
    holder.listHash.setText(codeList.get(position).getListHashText());
    imageLoader.DisplayImage(codeList.get(position).getAlphabetimg(),
                             holder.alphabetList);


    if (checkFavoriteItem(codes)) {
        holder.favariteImage.setImageResource(R.drawable.favorite);
        holder.favariteImage.setTag("yes");
    } else {
        holder.favariteImage.setImageResource(R.drawable.unfavorite);
        holder.favariteImage.setTag("no");
    }


    view.setOnClickListener(new OnClickListener(){

            @Override
            public void onClick(View arg0){
                Intent intent = new Intent(context, SingleItemView.class);

                //intent.putExtra("listheading",
                //       (codeList.get(position).getListHeading()));
                //intent.putExtra("alphabetimg",
                //              (codeList.get(position).getAlphabetimg()));

                intent.putExtra("demovideo",
                                (codeList.get(position).getDailogdemovideo()));


                context.startActivity(intent);

            }
        });


    return view;
}

主要活动oncrate()
listview = (ListView) findViewById(R.id.inter_layoutListView);
        // Pass the results into ListViewAdapter.java
        adapter = new FinalAdapter(InterActivity.this,
                                      codelist);

        listview.setAdapter(new SlideExpandableListAdapter(adapter, R.id.expandbutton, R.id.expandable));

最佳答案

public class ASummary extends Activity implements OnClickListener{

//.....
@Override
    protected void onCreate(Bundle savedInstanceState) {

        ///...
adapter = new FinalAdapter(InterActivity.this,
                                      codelist,this);
///...
}
//....
@Override
    public void onClick(View v) {
        int id = (Integer) v.getTag();

      }

}

FinalAdapter类中创建构造函数和OnClickListener变量:
private OnClickListener listener;
FinalAdapter(Context ctx,codelist, OnClickListener listener ){

///super....

this.listener = listener;
}

然后在getView中:
使用
view.setTag(position);
view.setOnClickListener(listener);

09-10 01:09