我有一个包含RelativeLayout的列表视图。我想在点击那个RelativeLayout上的那个相对布局中添加一个视图。这是代码
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
if(convertView==null)
{
holder=new ViewHolder_CurrentMatches();
convertView=inflater.inflate(R.layout.custom_matches, null);
holder.firstTeamLogoLayout=(RelativeLayout)convertView.findViewById(R.id.createLeague_firstTeamLogoLayout);
holder.wheel=new View(context);//The View i want to Add
convertView.setTag(holder);
}
else
{
holder=(ViewHolder_CurrentMatches)convertView.getTag();
}
setOnClick(holder.firstTeamLogoLayout,holder.wheel);
return convertView;
}
private void setOnClick(final RelativeLayout view1,final View w)
{
view1.setOnClickListener(new OnClickListener()
{
public void onClick(View v)
{
doThings(view1,w);
}
});
}
@SuppressLint("NewApi")
private void doThings(RelativeLayout view1,RelativeLayout view2,final WheelView w)
{
params1=new LayoutParams(view1.getMeasuredWidth()-10,view1.getMeasuredHeight()/2);
params1.addRule(RelativeLayout.CENTER_IN_PARENT);
w.setLayoutParams(params1);
view1.addView(w);
view1.setClickable(false);
}
我的类将BaseAdapter扩展为适配器..
问题是当我滚动视图然后已经附加在位置上的视图我没有点击..这是由列表视图回收完成的.. 请给我一个解决方案,以便我有适当的工人阶级。