Android Picasso无法加载图片

时间:2014-01-03 15:44:30

标签: android listview picasso

 public class ReviewsFragment extends Fragment {
ListView listView1;
@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.reviews_fragment, container, false);
    Weather weather_data[] = new Weather[]
            {
                new Weather("http://www.ezzylearning.com/images/ImagesNew/net_framework.png", "Cloudy"),
                new Weather("http://www.ezzylearning.com/images/ImagesNew/net_framework.png", "Showers")                    
            };

            WeatherAdapter adapter = new WeatherAdapter(getActivity(), 
                    R.layout.listview_item_row, weather_data);             

            listView1 = (ListView)view.findViewById(R.id.listView1);                 
            View header = getActivity().getLayoutInflater().inflate(R.layout.listview_header_row, null);
            listView1.addHeaderView(header);                
            listView1.setAdapter(adapter);
    return view;
}
public class Weather {
    public String icon;
    public String title;
    public Weather(){
        super();
    }

    public Weather(String icon, String title) {
        super();
        this.icon = icon;
        this.title = title;
    }
}
public class WeatherAdapter extends ArrayAdapter<Weather>{

    Context context; 
    int layoutResourceId;    
    Weather data[] = null;

    public WeatherAdapter(Context context, int layoutResourceId, Weather[] data) {
        super(context, layoutResourceId, data);
        this.layoutResourceId = layoutResourceId;
        this.context = context;
        this.data = data;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View row = convertView;
        WeatherHolder holder = null;

        if(row == null)
        {
            LayoutInflater inflater = ((Activity)context).getLayoutInflater();
            row = inflater.inflate(layoutResourceId, parent, false);

            holder = new WeatherHolder();
            holder.imgIcon = (ImageView)row.findViewById(R.id.imgIcon);
            holder.txtTitle = (TextView)row.findViewById(R.id.txtTitle);

            row.setTag(holder);
        }
        else
        {
            holder = (WeatherHolder)row.getTag();
        }

        Weather weather = data[position];
        holder.txtTitle.setText(weather.title);
     //   holder.imgIcon.setImageResource(weather.icon);
        Picasso.with(getActivity()).load(weather.icon).into(holder.imgIcon);

        return row;
    }

     class WeatherHolder
    {
        ImageView imgIcon;
        TextView txtTitle;
    }
}
}

logcat的:

01-03 15:25:41.641: E/Trace(1321): error opening trace file: No such file or directory (2)
01-03 15:25:42.261: E/AndroidRuntime(1321): FATAL EXCEPTION: main
01-03 15:25:42.261: E/AndroidRuntime(1321): java.lang.NoClassDefFoundError: com.squareup.picasso.Picasso
01-03 15:25:42.261: E/AndroidRuntime(1321):     at com.fifaworldcup2014.ReviewsFragment$WeatherAdapter.getView(ReviewsFragment.java:88)
01-03 15:25:42.261: E/AndroidRuntime(1321):     at android.widget.HeaderViewListAdapter.getView(HeaderViewListAdapter.java:220)
01-03 15:25:42.261: E/AndroidRuntime(1321):     at android.widget.AbsListView.obtainView(AbsListView.java:2267)
01-03 15:25:42.261: E/AndroidRuntime(1321):     at android.widget.ListView.makeAndAddView(ListView.java:1769)
01-03 15:25:42.261: E/AndroidRuntime(1321):     at android.widget.ListView.fillDown(ListView.java:672)
01-03 15:25:42.261: E/AndroidRuntime(1321):     at android.widget.ListView.fillFromTop(ListView.java:733)
01-03 15:25:42.261: E/AndroidRuntime(1321):     at android.widget.ListView.layoutChildren(ListView.java:1622)
01-03 15:25:42.261: E/AndroidRuntime(1321):     at android.widget.AbsListView.onLayout(AbsListView.java:2102)
01-03 15:25:42.261: E/AndroidRuntime(1321):     at android.view.View.layout(View.java:13754)
01-03 15:25:42.261: E/AndroidRuntime(1321):     at android.view.ViewGroup.layout(ViewGroup.java:4362)
01-03 15:25:42.261: E/AndroidRuntime(1321):     at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1649)
01-03 15:25:42.261: E/AndroidRuntime(1321):     at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1507)
01-03 15:25:42.261: E/AndroidRuntime(1321):     at android.widget.LinearLayout.onLayout(LinearLayout.java:1420)
01-03 15:25:42.261: E/AndroidRuntime(1321):     at android.view.View.layout(View.java:13754)
01-03 15:25:42.261: E/AndroidRuntime(1321):     at android.view.ViewGroup.layout(ViewGroup.java:4362)
01-03 15:25:42.261: E/AndroidRuntime(1321):     at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
01-03 15:25:42.261: E/AndroidRuntime(1321):     at android.view.View.layout(View.java:13754)
01-03 15:25:42.261: E/AndroidRuntime(1321):     at android.view.ViewGroup.layout(ViewGroup.java:4362)
01-03 15:25:42.261: E/AndroidRuntime(1321):     at android.support.v4.view.ViewPager.onLayout(ViewPager.java:1589)
01-03 15:25:42.261: E/AndroidRuntime(1321):     at android.view.View.layout(View.java:13754)
01-03 15:25:42.261: E/AndroidRuntime(1321):     at android.view.ViewGroup.layout(ViewGroup.java:4362)
01-03 15:25:42.261: E/AndroidRuntime(1321):     at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1649)
01-03 15:25:42.261: E/AndroidRuntime(1321):     at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1507)
01-03 15:25:42.261: E/AndroidRuntime(1321):     at android.widget.LinearLayout.onLayout(LinearLayout.java:1420)
01-03 15:25:42.261: E/AndroidRuntime(1321):     at android.view.View.layout(View.java:13754)
01-03 15:25:42.261: E/AndroidRuntime(1321):     at android.view.ViewGroup.layout(ViewGroup.java:4362)
01-03 15:25:42.261: E/AndroidRuntime(1321):     at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
01-03 15:25:42.261: E/AndroidRuntime(1321):     at android.view.View.layout(View.java:13754)
01-03 15:25:42.261: E/AndroidRuntime(1321):     at android.view.ViewGroup.layout(ViewGroup.java:4362)
01-03 15:25:42.261: E/AndroidRuntime(1321):     at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
01-03 15:25:42.261: E/AndroidRuntime(1321):     at android.view.View.layout(View.java:13754)
01-03 15:25:42.261: E/AndroidRuntime(1321):     at android.view.ViewGroup.layout(ViewGroup.java:4362)
01-03 15:25:42.261: E/AndroidRuntime(1321):     at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1649)
01-03 15:25:42.261: E/AndroidRuntime(1321):     at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1507)
01-03 15:25:42.261: E/AndroidRuntime(1321):     at android.widget.LinearLayout.onLayout(LinearLayout.java:1420)
01-03 15:25:42.261: E/AndroidRuntime(1321):     at android.view.View.layout(View.java:13754)
01-03 15:25:42.261: E/AndroidRuntime(1321):     at android.view.ViewGroup.layout(ViewGroup.java:4362)
01-03 15:25:42.261: E/AndroidRuntime(1321):     at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
01-03 15:25:42.261: E/AndroidRuntime(1321):     at android.view.View.layout(View.java:13754)
01-03 15:25:42.261: E/AndroidRuntime(1321):     at android.view.ViewGroup.layout(ViewGroup.java:4362)
01-03 15:25:42.261: E/AndroidRuntime(1321):     at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:1866)
01-03 15:25:42.261: E/AndroidRuntime(1321):     at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1687)
01-03 15:25:42.261: E/AndroidRuntime(1321):     at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:998)
01-03 15:25:42.261: E/AndroidRuntime(1321):     at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4212)
01-03 15:25:42.261: E/AndroidRuntime(1321):     at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
01-03 15:25:42.261: E/AndroidRuntime(1321):     at android.view.Choreographer.doCallbacks(Choreographer.java:555)
01-03 15:25:42.261: E/AndroidRuntime(1321):     at android.view.Choreographer.doFrame(Choreographer.java:525)
01-03 15:25:42.261: E/AndroidRuntime(1321):     at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
01-03 15:25:42.261: E/AndroidRuntime(1321):     at android.os.Handler.handleCallback(Handler.java:615)
01-03 15:25:42.261: E/AndroidRuntime(1321):     at android.os.Handler.dispatchMessage(Handler.java:92)
01-03 15:25:42.261: E/AndroidRuntime(1321):     at android.os.Looper.loop(Looper.java:137)
01-03 15:25:42.261: E/AndroidRuntime(1321):     at android.app.ActivityThread.main(ActivityThread.java:4745)
01-03 15:25:42.261: E/AndroidRuntime(1321):     at java.lang.reflect.Method.invokeNative(Native Method)
01-03 15:25:42.261: E/AndroidRuntime(1321):     at java.lang.reflect.Method.invoke(Method.java:511)
01-03 15:25:42.261: E/AndroidRuntime(1321):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
01-03 15:25:42.261: E/AndroidRuntime(1321):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
01-03 15:25:42.261: E/AndroidRuntime(1321):     at dalvik.system.NativeStart.main(Native Method)

0 个答案:

没有答案