Android Udacity:ResourceException 0xfffffffff

时间:2017-04-08 19:04:57

标签: java android resources

This is the link to my app我是udacity website中的一个项目。

我使用的是回收者视图而不是列表视图...而且其他一切都是相同的 当我从工具栏中单击 up 按钮时,会出现错误 它给出了一个

  

资源未找到异常

但按下物理后退按钮时其他一切似乎都没问题。
我似乎无法弄清楚错误的原因是什么,找不到哪个资源以及为什么它只出现在单击 up 按钮而不是 back 按钮......?

My CursorRecyclerViewAdapter 

    Context mContext;
    public final static int View_Type_Today = 0 ;
    public final static int View_Type_Future = 1 ;

    public MyListCursorAdapter(Context context,Cursor cursor){
        super(context,cursor);
        mContext = context;
    }



    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        int layoutID= -1;
        if(viewType==View_Type_Today){
            layoutID = R.layout.list_item_forecast_today;
        }
        else{
            layoutID = R.layout.list_item_forecast;
        }
        View itemView = LayoutInflater.from(parent.getContext())
                .inflate(layoutID, parent, false);
        ViewHolder vh = new ViewHolder(itemView);
        return vh;
    }

    @Override
    public void onBindViewHolder(final ViewHolder holder, final Cursor cursor) {
        boolean isMetric = Utility.isMetric(mContext);
        holder.tvDate.setText(Utility.getFriendlyDayString(mContext,cursor.getLong(COL_WEATHER_DATE)));
        holder.low.setText(Utility.formatTemperature(mContext,cursor.getDouble(COL_WEATHER_MIN_TEMP),isMetric));
        holder.high.setText(Utility.formatTemperature(mContext,cursor.getDouble(COL_WEATHER_MAX_TEMP),isMetric));
        holder.desc.setText(getDesc(cursor));
        final int position = cursor.getPosition();
        int viewType = getItemViewType(position);
        switch (viewType) {
            case View_Type_Today: {
                // Get weather icon
                int Res = Utility.getArtResourceForWeatherCondition(cursor.getInt(COL_WEATHER_CONDITION_ID));
                holder.iv.setImageResource(Res);
                    break;
            }
            case View_Type_Future: {
                // Get weather icon
                holder.iv.setImageResource(Utility.getIconResourceForWeatherCondition(
                        cursor.getInt(activity_main_fragment.COL_WEATHER_CONDITION_ID)));
                break;
            }
        }
        holder.container.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                cursor.moveToPosition(position);
                String locationSetting = Utility.getPreferredLocation(mContext);
                Intent in = new Intent(mContext,DetailActivity.class).setData(WeatherContract.WeatherEntry
                        .buildWeatherLocationWithDate(locationSetting,cursor.getLong(COL_WEATHER_DATE)));
                mContext.startActivity(in);
            }
        });
    }
    private String getDesc(Cursor cursor){
        return cursor.getString(COL_WEATHER_DESC);
    }

    @Override
    public int getItemViewType(int position) {
        return (position ==0) ? View_Type_Today : View_Type_Future;
    }
}

Viewholder类

  TextView tvDate;
  TextView high;
  TextView low;
  TextView desc;
        View container;
        ImageView iv;
        public ViewHolder(View itemView) {
            super(itemView);
            desc= (TextView)itemView.findViewById(R.id.list_item_forecast_textview);
            high= (TextView)itemView.findViewById(R.id.list_item_high_textview);
            low= [enter image description here][1](TextView)itemView.findViewById(R.id.list_item_low_textview);
            tvDate= (TextView)itemView.findViewById(R.id.list_item_date_textview);
            iv = (ImageView) itemView.findViewById(R.id.list_item_icon);
            container = itemView;
        }

0 个答案:

没有答案