ListView异常行为仅点击奇数条目

时间:2013-12-24 11:31:49

标签: android android-listview

我试图点击listView中的特定元素,但只点击了Odd元素。我在listView中添加了一个标题。(在我注意到这个bug之前的最后一次更改)。 如果有任何事情需要,请告诉我。

 View headerView = ((LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.header, null, false);
                listView.addHeaderView(headerView);

                View footerView =  ((LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.listview_footer, null, false);
                listView.addFooterView(footerView);
    listView.setOnItemClickListener(new OnItemClickListener() {
                public void onItemClick(AdapterView<?> parent, View view,
                        int pos, long id) { 
                    }



@Override
        public View getView(final int posi, View convertView, ViewGroup parent)
        {  
            ViewHolder holder = null;
            TextView status = null;
            TextView awbNumber = null;

            //String name=null;
            TextView imageView=null;


            final RowData rowData= getItem(posi);
            if(null == convertView)

            {
                convertView = layoutInflator.inflate(R.layout.episode_list, null);
                holder = new ViewHolder(convertView);
                convertView.setTag(holder);
            }/*else{
                       convertView = getTag();
                }*/

            holder = (ViewHolder) convertView.getTag();


            //  ////System.out.println("onkar trying to set name"+rowData.intId+""+rowData.StrID+""+rowData.strname);
            //  awbNumber.setText(rowData.strname );

            status=holder.getEpisodeName();


            imageView=holder.getEpisodeSequence();
            imageView.setText(rowData.count);

            status.setText(rowData.strname);
            imageView.setTypeface(myTypeface);

            status.setTypeface(myTypeface);

            if(position==rowData.intId){
                status.setTextColor(Color.RED);
                ////System.out.println("position is "+position+" "+rowData.StrID);
            }else{
                status.setTextColor(Color.BLACK);
            }


            return convertView;
        }

        @Override
        public void onClick(View v) {

        }

    }

1 个答案:

答案 0 :(得分:0)

我忽略了标题成为ListView元素的面孔。