伙计们帮助我解决这个错误(错误),我找不到此错误....所以请帮助找到并销毁此错误.....

一些代码:

public class GridOdAdapter  extends BaseAdapter {
String[] Description;
String[] Title;
int[] Minute;
int[] Hour;
int[] Day;
int[] Month;
int[] Year;
int mId;
public String[] mThumbIds;
String[]mCoulor;
int[] iconResId;
private Context mContext;
List<OneDayTD> oneDayTDList;


public GridOdAdapter(Context c, List<OneDayTD> oneDayTDList1) {
    mContext = c;
    oneDayTDList = oneDayTDList1;
    int d = oneDayTDList.size();
    String i= ""+d;
    Log.d("MyLog",oneDayTDList.get(0).getTitle());
    Log.d("MyLog",i);
}

public int getCount() {
    return oneDayTDList.size();
}

public Object getItem(int position) {
    return oneDayTDList.get(position).getTitle();
}

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


@Override
public View getView(int position, View convertView, ViewGroup parent) {
    // TODO Auto-generated method stub

    View grid;
    LayoutInflater inflater = (LayoutInflater) mContext.getSystemService( Context.LAYOUT_INFLATER_SERVICE );

    iconResId = new int[mId];
    for (int i=0;i==mThumbIds.length;i++){

        //iconResId = new int[mId];
        iconResId[i] = mContext.getResources().getIdentifier(mThumbIds[i],"drawable",mThumbIds[i]);

    }
    if (convertView == null) {
        grid = new View(mContext);


        grid = inflater.inflate(R.layout.grid_od,null);
        ImageView imageView = (ImageView) grid.findViewById(R.id.imagepart);
        ImageView imageView1 = (ImageView) grid.findViewById(R.id.circle);
        TextView textView = (TextView) grid.findViewById(R.id.textpart);

        TextView textView2 = (TextView) grid.findViewById(R.id.texttime);

        TextView textView4 = (TextView) grid.findViewById(R.id.Timer);
        TextView textView5 = (TextView) grid.findViewById(R.id.textpart2);

        int iconResId = mContext.getResources().getIdentifier(oneDayTDList.get(position).getIcon(), "drawable", mContext.getPackageName());
        imageView.setImageResource(iconResId);
        GradientDrawable bgShape = (GradientDrawable) imageView1.getDrawable();
        bgShape.setColor(Color.parseColor(oneDayTDList.get(position).getColour()));

        //imageView.setColorFilter(parseColor(mCoulor[position]));
        textView.setText(oneDayTDList.get(position).getTitle());
        textView5.setText(oneDayTDList.get(position).getContent());
        //textView2.setText("Year: "+Year[position] + " Month: " + Month[position] + " Day: " + Day[position] + " Hour: "+ Hour[position] + " Minute: " + Minute[position]);
        //textView4.setText(Title[position]);

    } else {
        grid = (View) convertView;
    }




    return grid;
}

// references to our images

}


Log{

FATAL EXCEPTION: main
      Process: com.universe.time.officereminder, PID: 31432
      java.lang.NullPointerException: Attempt to get length of null array
          at com.universe.time.proffesionaldiary.adapters.GridOdAdapter.getView(GridOdAdapter.java:69)
          at android.widget.AbsListView.obtainView(AbsListView.java:2828)
          at android.widget.GridView.onMeasure(GridView.java:1064)
          at android.view.View.measure(View.java:18647)
          at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5832)
          at android.widget.FrameLayout.onMeasure(FrameLayout.java:430)
          at android.view.View.measure(View.java:18647)
          at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5832)
          at android.widget.FrameLayout.onMeasure(FrameLayout.java:430)
          at android.view.View.measure(View.java:18647)
          at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5832)
          at android.support.design.widget.CoordinatorLayout.onMeasureChild(CoordinatorLayout.java:664)
          at android.support.design.widget.HeaderScrollingViewBehavior.onMeasureChild(HeaderScrollingViewBehavior.java:90)
          at android.support.design.widget.AppBarLayout$ScrollingViewBehavior.onMeasureChild(AppBarLayout.java:1139)
          at android.support.design.widget.CoordinatorLayout.onMeasure(CoordinatorLayout.java:729)
          at android.view.View.measure(View.java:18647)
          at android.support.v4.widget.DrawerLayout.onMeasure(DrawerLayout.java:1071)
          at android.view.View.measure(View.java:18647)
          at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5832)
          at android.widget.FrameLayout.onMeasure(FrameLayout.java:430)
          at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:135)
          at android.view.View.measure(View.java:18647)
          at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5832)
          at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1435)
          at android.widget.LinearLayout.measureVertical(LinearLayout.java:721)
          at android.widget.LinearLayout.onMeasure(LinearLayout.java:612)
          at android.view.View.measure(View.java:18647)
          at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5832)
          at android.widget.FrameLayout.onMeasure(FrameLayout.java:430)
          at android.view.View.measure(View.java:18647)
          at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5832)
          at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1435)
          at android.widget.LinearLayout.measureVertical(LinearLayout.java:721)
          at android.widget.LinearLayout.onMeasure(LinearLayout.java:612)
          at android.view.View.measure(View.java:18647)
          at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5832)
          at android.widget.FrameLayout.onMeasure(FrameLayout.java:430)
          at android.view.View.measure(View.java:18647)
          at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5832)
          at android.widget.FrameLayout.onMeasure(FrameLayout.java:430)
          at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:3012)
          at android.view.View.measure(View.java:18647)
          at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2298)
          at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1345)
          at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1588)
          at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1230)
          at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6748)
          at android.view.Choreographer$CallbackRecord.run(Choreographer.java:777)
          at android.view.Choreographer.doCallbacks(Choreographer.java:590)
          at android.view.Choreographer.doFrame(Choreographer.java:560)
          at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:763)
          at android.os.Handler.handleCallback(Handler.java:739)
          at android.os.Handler.dispatchMessage(Handler.java:95)
          at android.os.Looper.loop(Looper.java:145)
          at android.app.ActivityThread.main(ActivityThread.java:6126)
          at java.lang.reflect.Method.invoke(Native Method)
          at java.lang.reflect.Method.invoke(Method.java:372)
          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
        at com

}

最佳答案

您要获取空对象的长度,因为到达以下行时,mThumbIds为空:for (int i=0;i==mThumbIds.length;i++){

关于android - Android GridView适配器崩溃,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/36161657/

10-10 19:50