getview()方法无法正常工作

时间:2013-12-30 11:54:57

标签: android android-listview position

在我的项目中,我从sqlite数据库填充listview。当我单击列表行时,它将显示在所选行的详细视图中。当我单击列表行时它将消息ID从sqlite数据库传递到详细视图该行的详细内容将从sqlite数据库中获取。但是它显示了所选行的错误细节。这是我的代码,任何人都可以帮助我!

    public View getView(int position, View convertView, ViewGroup parent) {

            View row = convertView;  
            UserHolder holder = null;
            System.out.println("positionnnn:"+position);
            if (row == null) {

            //   LayoutInflater inflater= (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                  //  v = vi.inflate(R.layout.list_item_message, null);
            LayoutInflater inflater = context.getLayoutInflater();
            System.out.println("positionnnn:"+position);



            row = inflater.inflate(R.layout.inboxcustom,parent,false);

            holder = new UserHolder();
            holder.fromnum = (TextView) row.findViewById(R.id.fromno);
            holder.tonum = (TextView) row.findViewById(R.id.tonum);
            holder.body= (TextView) row.findViewById(R.id.msgbody);
            holder.date = (TextView) row.findViewById(R.id.msgdate);
            holder.readunread=(ImageView) row.findViewById(R.id.imageView1);

            row.setTag(holder);
            } else {
            holder = (UserHolder) row.getTag();
            }
            user = data.get(position);
            System.out.println("user:::::" + user);
            smsm=user.getID();
            System.out.println("Smsm::::"+smsm);
            System.out.println("Array list size in getview method inbox:::"+data.size());
            holder.fromnum.setText(user.getmsgfrom());
            holder.tonum.setText(user.getto());
            holder.body.setText(user.getmsg());
            holder.date.setText(user.getdate());
           // holder.status.setText(user.getstatus());
        //    holder.readunread.set
         System.out.println("status value:::"+user.getstatus());
         String zero="0";
         System.out.println("Zero value:::"+zero);
            if(user.getstatus().equals(zero)){
                 int  dailyun=dbHandler.calculateunread();
                 System.out.println("unreadcount in inbox activity::"+dailyun);

        holder.readunread.setImageResource(R.drawable.messageunread);
            } 

           row.setOnClickListener(new OnItemClickListener(position));

            return row;

        }

请有人帮助我!先谢谢!!!

0 个答案:

没有答案