private class MyBaseMsgAdapter extends BaseAdapter { //获取数据适配器中条目类型的总数,修改成两种(纯文本,输入+文字) @Override public int getViewTypeCount() { //条目类型数(这里有两种类型) return super.getViewTypeCount() + 1; } //指定索引指向的条目类型,条目类型指定(0(复用系统),1) @Override public int getItemViewType(int position) { if (position == 0) { //返回0,表示纯文本的状态码 return 0; } else { //返回1,表示输入+文字的状态码 return 1; } } @Override public int getCount() { return mTitleContent.length; } @Override public String getItem(int position) { return mTitleContent[position]; } @Override public long getItemId(int position) { return position; } @Override public View getView(int position, View convertView, ViewGroup parent) { int type = getItemViewType(position); if (type == 0) { View v = null; ViewHolder mViewHolder = null; if (convertView == null) { mViewHolder = new ViewHolder(); v = View.inflate(getApplicationContext(), R.layout.item_loan_base_title, null); mViewHolder.tv_base = (TextView) v.findViewById(R.id.tv_base); v.setTag(mViewHolder); } else { v = convertView; mViewHolder = (ViewHolder) v.getTag(); } mViewHolder.tv_base.setText(mTitleContent[position]); return v; } else { View v = null; ViewHolder mViewHolder = null; if (convertView == null) { mViewHolder = new ViewHolder(); v = View.inflate(getApplicationContext(), R.layout.item_loan_application, null); mViewHolder.tv_base_title = (TextView) v.findViewById(R.id.tv_base_title); mViewHolder.et_base_input = (EditText) v.findViewById(R.id.et_base_input); } else { v = convertView; mViewHolder = (ViewHolder) v.getTag(); } mViewHolder.tv_base_title.setText(mTitleContent[position]); mViewHolder.et_base_input.setHint(mInputContent[position]); return v; } }} class ViewHolder { private TextView tv_base; private EditText et_base_input; private TextView tv_base_title;}这里面有一个问题,就是在模拟器上面如果ListView给定的太小,文字放不下,那么就可以滑动!但是大家都知道,鼠标可以直接滑动,当鼠标不选中滑动的话,程序就挂掉了,然后选中又没事。于是我就在真机上测试,也没问题,那么问题来了,这个错误是怎么造成的呢?两种可能嘛,1.模拟器的问题,2.代码的问题。这个问题还没解决,等解决了再继续更......
时间: 2024-10-02 23:37:59