2014-01-13 146 views
-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異常?

+3

Logcat請。 – Razgriz

+0

和logcat? –

+0

請發佈異常堆棧跟蹤 – Srikanth

回答

2

你指明當你點擊一個數據,你得到一個崩潰。由於您可以看到所有列表和其中的數據,因此問題不在於您的適配器。你應該發佈你的列表項目單擊事件。你可能正在用你的_alluserlist數組做一些事情,這會讓你崩潰。

+1

是的,先生,我是設置適配器的循環,所以我的應用程序崩潰,thnku這麼多.. :) – rajshree

相關問題