|
请教达人,Log.i只显示到5就报错。
list.setAdapter(adapter);哪里出错了?求助~
public class main extends Activity {
public static final String tag = "main";
public static List<LawyerDetail> mLawyerList;
private EfficientAdapter adapter = null;
private static class EfficientAdapter extends BaseAdapter {
private LayoutInflater mInflater;
public EfficientAdapter(Context context) {
mInflater = LayoutInflater.from(context);
}
public int getCount() {
return mLawyerList.size();
}
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
return position;
}
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
if (convertView == null) {
convertView = mInflater.inflate(R.layout.lawyer_item, null);
holder = new ViewHolder();
holder.addr = (TextView) convertView.findViewById(R.id.addr);
holder.cityPro = (TextView) convertView.findViewById(R.id.cityPro);
holder.phone = (TextView) convertView.findViewById(R.id.phone);
holder.addr.setTextColor(Color.BLACK);
holder.cityPro.setTextColor(Color.BLACK);
holder.phone.setTextColor(Color.BLACK);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
holder.addr.setText(mLawyerList.get(position).getAddr());
holder.cityPro.setText(mLawyerList.get(position).getCity()+","+mLawyerList.get(position).getProvince()+" "+ mLawyerList.get(position).getPostal());
holder.phone.setText(mLawyerList.get(position).getPhone());
return convertView;
}
static class ViewHolder {
TextView addr;
TextView cityPro;
TextView phone;
}
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.i(tag, "1~~~~~");
AsyncFromServer afs = new AsyncFromServer(main.this);
afs.execute("getlawyersByLoc");
Log.i(tag, "2~~~~~");
this.setContentView(R.layout.list);
Log.i(tag, "3~~~~~");
ListView list = (ListView) this.findViewById(R.id.mylist);
Log.i(tag, "4~~~~~");
adapter = new EfficientAdapter(this);
Log.i(tag, "5~~~~~");
//setListAdapter(adapter);
list.setAdapter(adapter);
Log.i(tag, "6~~~~~");
list.setOnItemClickListener(new OnItemClickListener(){
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Log.d(tag,"onItemClick:"+position);
}
}
);
Log.i(tag, "7~~~~~");
list.setBackgroundColor(Color.parseColor("#FFFFFF"));}
// list.setBackgroundResource(R.drawable.background);
//mapViewButton.setVisibility(View.INVISIBLE); ?3D??????? |
|