0
public class SampleInbox extends ListActivity {
    private EfficientAdapter adap;
    String strUrl;
    InboxBean iBean;
    InboxBean inboxBean;
    XmlParser parser;
    ArrayList<Object>  result;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.main_content);
        adap = new EfficientAdapter(this);
        setListAdapter(adap);

    }

    @Override
    protected void onListItemClick(ListView l, View v, int position, long id) {
        // TODO Auto-generated method stub
        super.onListItemClick(l, v, position, id);
        Toast.makeText(this, "Click-" + String.valueOf(position), Toast.LENGTH_SHORT).show();
    }

    public static class EfficientAdapter extends BaseAdapter implements Filterable {
        private LayoutInflater mInflater;
        private Bitmap mIcon1;
        private Context context;
        String strUrl;
        InboxBean iBean;
        InboxBean inboxBean;
        XmlParser parser;
        ArrayList<Object>  result;

        public EfficientAdapter(Context context) {
            // Cache the LayoutInflate to avoid asking for a new one each time.
            mInflater = LayoutInflater.from(context);
            this.context = context;

            strUrl = "http://192.168.5.10/ijoomer_test/index.php?option=com_community&view=frontpage&task=inbox_xml&id="+ConstantData.user_id+"&sessionid="+ConstantData.session_id+"&tmpl=component";
            parser = new XmlParser(strUrl, new InboxBean());
            result = parser.ParseUrl("data", "message");
        }

        public View getView(final int position, View convertView, ViewGroup parent) {
            ViewHolder holder;

            if (convertView == null) {
                convertView = mInflater.inflate(R.layout.adapter_content, null);
                holder = new ViewHolder();
                holder.textLine = (TextView) convertView.findViewById(R.id.textLine);
                holder.iconLine = (ImageView) convertView.findViewById(R.id.iconLine);
                holder.txtBodyList = (TextView) convertView.findViewById(R.id.txtBodyList);
                holder.txtPostDate = (TextView) convertView.findViewById(R.id.txtPostDate);

                convertView.setOnClickListener(new OnClickListener() {
                    private int pos = position;
                    @Override
                    public void onClick(View v) {
                        Toast.makeText(context, "Click-" + String.valueOf(pos), Toast.LENGTH_SHORT).show();   
                    }
                });


                convertView.setTag(holder);
            } else {
                holder = (ViewHolder) convertView.getTag();
            }

            holder.iconLine.setImageBitmap(mIcon1);
            // holder.textLine.setText("flag " + String.valueOf(position));

            for(int i=0; i<result.size(); ++i)
            {

                iBean = (InboxBean)result.get(i);
                holder.textLine.setText(iBean.subject);
                holder.txtBodyList.setText(iBean.body);
                Log.d("Position", ""+iBean);
                Log.d("Position", ""+iBean.subject);
                holder.txtPostDate.setText(iBean.postdate);
            }

            return convertView;
        }

        static class ViewHolder {
            TextView textLine;
            ImageView iconLine;
            //  Button buttonLine;
            TextView txtBodyList;
            TextView txtPostDate;
        }
        @Override
        public Filter getFilter() {
            // TODO Auto-generated method stub
            return null;
        }
        @Override
        public long getItemId(int position) {
            // TODO Auto-generated method stub
            return 0;
        }

        @     Override
        public int getCount() {
            // TODO Auto-generated method stub

            Log.d("Counter", ""+result.size());
            return result.size();
        }
        @Override
        public Object getItem(int position) {
            // TODO Auto-generated method stub
            return 0;
        }
    }
}

In above code, i am getting records from webservice. The problem is that there are total 12 records and i am getting 12 records but in each row the last record is print please give me solution

2
  • You are receiving 12 records from the Webservice. The last record is print. I couldn't get you here... Are you getting "print" in all columns of the last row? Commented Apr 8, 2011 at 4:13
  • i am getting 12 rows with same data(last record).... Commented Apr 8, 2011 at 4:14

1 Answer 1

1

you have for loop in your adapter class...which was not needed at all....if u want to assign value to textboxes then just do it for only one time..remove for loop...

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.