android片段baseadapter getcount被调用但不是getview

时间:2013-06-01 07:42:00

标签: android listview fragment baseadapter

我有片段,其中我有一个列表视图,我试图在列表中显示一些数据。它很愚蠢,但它不起作用我不知道它有什么问题。

在oncreateview中我的fragmnet中这样做

mContactsHomeAdapter = new ContactsHomeAdapter(getActivity());
    mListView.setAdapter(mContactsHomeAdapter);
    mContactsHomeAdapter.notifyDataSetChanged();

这是我的适配器代码

    public class ContactsHomeAdapter extends BaseAdapter {
    ExecutorService executorService;
    private Context mContext;
    LayoutInflater mInflater;


    public ContactsHomeAdapter(Context pContext) {
        mContext = pContext;
         //executorService=Executors.newFixedThreadPool(10);
         mInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }

    @Override
    public int getCount() {
        return 100;
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if(convertView == null){
            convertView = mInflater.inflate(R.layout.contacts_adapter_item, null);
        }

        CheckBox lCheckbox = (CheckBox) convertView.findViewById(R.id.check_box);
        TextView lContactTitle = (TextView) convertView.findViewById(R.id.contact_title);
        TextView lContactEmail = (TextView) convertView.findViewById(R.id.contact_email);
        ImageView lContactPhoto = (ImageView) convertView.findViewById(R.id.contact_photo);
        TextView lContactNumber = (TextView) convertView.findViewById(R.id.contact_phonenumber);

        lContactTitle.setText("hello");

//      QueueItem  lItem = new QueueItem() ;
//      lItem.mId = ""+position;
//      lItem.mName = lContactTitle;
//      lItem.mNumber = lContactNumber;
//      lItem.mEmail = lContactEmail;
//       executorService.submit(new QueueRunner(lItem));
        return convertView;
    }
}

0 个答案:

没有答案