我想在此页面上显示横幅:http://abcsur.info/clasificados/inmuebles/casas
这是我获取它的代码
Document document = Jsoup.connect(url).get();
Elements img = document.select("div.col-sm-12.A4DZP4C3.well.leaderboard-A4DZP4C3.genericContainer.js-A4DZP4C3.js-leaderboard-A4DZP4C3");
// Locate the src attribute
String imgSrc = img.attr("src");
// Download image from URL
InputStream input = new java.net.URL(imgSrc).openStream();
// Decode Bitmap
bitmap = BitmapFactory.decodeStream(input);
并在ImageView中显示它
ImageView logoimg = (ImageView) findViewById(R.id.publicidad);
logoimg.setImageBitmap(bitmap);
不要工作。
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ImageView.setImageBitmap(android.graphics.Bitmap)' on a null object reference
at info.blacktrail.abcsur.InmueblesFolder.Casas$Title.onPostExecute(Casas.java:135)
at info.blacktrail.abcsur.InmueblesFolder.Casas$Title.onPostExecute(Casas.java:76)
答案 0 :(得分:1)
ImageView logoimg = (ImageView) findViewById(R.id.publicidad);
logoimg.setImageBitmap(bitmap);
在上面的代码logoimg
中为空。