Android arrayadapter 在listview android java中使用毕加索设置imageview

Android arrayadapter 在listview android java中使用毕加索设置imageview,android-arrayadapter,picasso,Android Arrayadapter,Picasso,我正在使用毕加索设置我的imageview,因为我只有我的图像的url。我已经使用listview来显示。在自定义适配器中,我使用毕加索设置imageview。但图像不会显示在listview中。我不知道问题出在哪里。。。有人帮我解决这个问题吗。。。。提前谢谢 public class GetReportAdapter extends ArrayAdapter<NewsReport> { private ArrayList<NewsReport> newsRepo

我正在使用毕加索设置我的imageview,因为我只有我的图像的url。我已经使用listview来显示。在自定义适配器中,我使用毕加索设置imageview。但图像不会显示在listview中。我不知道问题出在哪里。。。有人帮我解决这个问题吗。。。。提前谢谢

public class GetReportAdapter extends ArrayAdapter<NewsReport> {
    private ArrayList<NewsReport> newsReports;
    public GetReportAdapter(Context context, ArrayList<NewsReport> newsReportArrayList)
    {
        super(context, 0,newsReportArrayList);
        this.newsReports=newsReportArrayList;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View listItemView = convertView;
        if (listItemView == null) {
            listItemView = LayoutInflater.from(getContext()).inflate(
                    R.layout.list_item, parent, false);
        }
        NewsReport currentReport=getItem(position);

        TextView titleTextView=(TextView) listItemView.findViewById(R.id.title_text_view);
        titleTextView.setText(currentReport.getTitle());
        TextView channelTextView=(TextView) listItemView.findViewById(R.id.news_channel_text_view);
        channelTextView.setText(currentReport.getChannel());
        ImageView pictureImageView=(ImageView) listItemView.findViewById(R.id.news_pic_image_view);
        Log.e("image urlString",currentReport.getImage());
        Picasso.with(listItemView.getContext()).load(currentReport.getImage()).into(pictureImageView);
        return listItemView;
    }
}

公共类GetReportAdapter扩展了ArrayAdapter{
私人ArrayList新闻报道;
公共GetReportAdapter(上下文上下文,ArrayList newsReportArrayList)
{
超级(上下文,0,newsReportArrayList);
this.newsReports=newsReportArrayList;
}
@凌驾
公共视图getView(int位置、视图转换视图、视图组父视图){
View listItemView=convertView;
如果(listItemView==null){
listItemView=LayoutFlater.from(getContext()).inflate(
R.layout.list_项,父项,false);
}
NewsReport currentReport=getItem(位置);
TextView titleTextView=(TextView)listItemView.findViewById(R.id.title\u text\u视图);
titleTextView.setText(currentReport.getTitle());
TextView channelTextView=(TextView)listItemView.findViewById(R.id.news\u channel\u text\u view);
channelTextView.setText(currentReport.getChannel());
ImageView图片图像视图=(ImageView)listItemView.findViewById(R.id.news\u pic\u image\u view);
Log.e(“image urlString”,currentReport.getImage());
Picasso.with(listItemView.getContext()).load(currentReport.getImage()).into(pictureImageView);
返回listItemView;
}
}
这里我正在设置listview

public class MainActivity extends AppCompatActivity {
    static final Uri CONTENT_URL = Uri.parse("content://com.example.newsreport/newsfeed");
    ContentResolver resolver;
    ArrayList<NewsReport> newsReportArrayList = new ArrayList<NewsReport>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.list);
        resolver = getContentResolver();
        Log.e("resolver", "" + resolver);
        getNewsFeed();
        setAdapter();
    }

    public void getNewsFeed() {
        String id = null;
        String title = null;
        String content = null;
        String channel = null;
        String image = null;

        String[] projection = new String[]{BaseColumns._ID, "title", "channel", "image", "content"};
        Cursor cursor = getContentResolver().query(CONTENT_URL, projection, null, null, null);
        String newsFeed = "";
        if (cursor.moveToNext()) {
            do {
                id = cursor.getString(cursor.getColumnIndex(BaseColumns._ID));
                title = cursor.getString(cursor.getColumnIndex("title"));
                Log.e("title", title);
                content = cursor.getString(cursor.getColumnIndex("content"));
                Log.e("content", "" + content);
                channel = cursor.getString(cursor.getColumnIndex("channel"));
                Log.e("channel", "" + channel);
                image = cursor.getString(cursor.getColumnIndex("image"));
                Log.e("image", "" + image);
                newsReportArrayList.add( new NewsReport(channel,title,image));
            } while (cursor.moveToNext());


        }
    }
    public void setAdapter()
    {
        ListView list=(ListView) findViewById(R.id.list);
        GetReportAdapter adapter= new GetReportAdapter(this,newsReportArrayList);
        list.setAdapter(adapter);
    }
}

public类MainActivity扩展了AppCompatActivity{
静态最终Uri内容\u URL=Uri.parse(“content://com.example.newsreport/newsfeed");
内容解析器;
ArrayList newsReportArrayList=新的ArrayList();
@凌驾
创建时受保护的void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.list);
解析程序=getContentResolver();
Log.e(“解析器”,“解析器+解析器”);
getNewsFeed();
setAdapter();
}
public void getNewsFeed(){
字符串id=null;
字符串标题=null;
字符串内容=null;
字符串通道=空;
字符串image=null;
字符串[]投影=新字符串[]{BaseColumns.\u ID,“标题”,“频道”,“图像”,“内容”};
Cursor Cursor=getContentResolver().query(CONTENT\u URL,projection,null,null,null);
字符串newsFeed=“”;
if(cursor.moveToNext()){
做{
id=cursor.getString(cursor.getColumnIndex(BaseColumns.\u id));
title=cursor.getString(cursor.getColumnIndex(“title”);
日志e(“标题”,标题);
content=cursor.getString(cursor.getColumnIndex(“content”);
Log.e(“内容”和“+内容);
channel=cursor.getString(cursor.getColumnIndex(“channel”);
Log.e(“通道”,“通道+通道”);
image=cursor.getString(cursor.getColumnIndex(“image”);
Log.e(“图像”,“图像+图像”);
添加(新的新闻报道(频道、标题、图片));
}while(cursor.moveToNext());
}
}
公共void setAdapter()
{
ListView列表=(ListView)findViewById(R.id.list);
GetReportAdapter=新的GetReportAdapter(这是newsReportArrayList);
list.setAdapter(适配器);
}
}