-3
public class GridAllUserAdapter extends BaseAdapter{
private LayoutInflater _mInflater = null;
private ArrayList<Object>_alluserlist=null;
private Activity _activity = null;
TabGroupActivity parentActivity = null;
ImageLoader imageLoader=null;
/**
* @param activity
* @param itemList
*/
public GridAllUserAdapter(Activity activity, ArrayList<Object> itemList) {
this._activity = activity;
this._alluserlist = itemList;
imageLoader=new ImageLoader(_activity);
_mInflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
parentActivity=(TabGroupActivity)_activity.getParent();
}
public int getCount() {
return _alluserlist.size();
}
public Object getItem(int position) {
return _alluserlist.get(position);
}
public long getItemId(int position) {
return position;
}
static class ViewHolder {
public ImageView imgViewFlag;
public TextView txtViewTitle;
}
public View getView(final int position, View convertView, ViewGroup parent) {
final ViewHolder holder;
if (convertView == null) {
convertView = _mInflater.inflate(R.layout.custom_gridview_row, null);
holder = new ViewHolder();
holder.txtViewTitle = (TextView) convertView.findViewById(R.id.pic_name_txt);
holder.imgViewFlag = (ImageView) convertView.findViewById(R.id.photo_frameImg);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
final AllBean bean=(AllBean)_alluserlist.get(position);
holder.txtViewTitle.setText(bean.getusername());
imageLoader.DisplayImage(bean.getprofile_photo(), R.drawable.default_profile_pic, holder.imgViewFlag);
return convertView;
}
// Filter Class
public void filter(String charText) {
charText = charText.toLowerCase(Locale.getDefault());
_alluserlist.clear();
if (charText.length() == 0) {
_alluserlist.addAll(_alluserlist);
} else {
for (Object bean : _alluserlist) {
if (((AllBean) bean).getusername().toLowerCase(Locale.getDefault())
.contains(charText)) {
_alluserlist.add(bean);
}
}
}
notifyDataSetChanged();
}
}
我有gridview數據來自服務器。當我點擊按鈕時,數據顯示並突然我的應用程序停止。它讓我在拋出:ArrayIndexOutOfBoundsException .. getview,適配器..請幫助我..Android ArrayIndexOutOfBoundsException異常?
Logcat請。 – Razgriz
和logcat? –
請發佈異常堆棧跟蹤 – Srikanth