Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/198.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 使用基本适配器的列表视图循环_Android - Fatal编程技术网

Android 使用基本适配器的列表视图循环

Android 使用基本适配器的列表视图循环,android,Android,我有一个带有RelativeLayout的列表视图。我想在单击RelativeLayout时在该相对布局中添加一个视图。下面是代码 @Override public View getView(int position, View convertView, ViewGroup parent) { // TODO Auto-generated method stub if(convertView==null) { hol

我有一个带有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扩展为适配器

问题是,当我滚动视图时,视图已经附着在我没有单击的位置上。这是通过列表视图循环完成的。。 请给我一个解决方案,这样我才能有一个合适的工人阶级