我收到错误:目标不能为空毕加索
public void getListFromDb(){
Cursor res = myDb.ViewAll();
startManagingCursor(res);
//Map cursor from db to viewFields
String[] fromFieldNames = new String[]{DatabaseHelper.COL_2, DatabaseHelper.COL_3, DatabaseHelper.COL_4, DatabaseHelper.COL_5};
int[] toViewIDS = new int[]{R.id.viewName, R.id.viewAddress, R.id.viewPostcode, R.id.viewType};
//Create SimpleCursorAdaptor with null cursor
SimpleCursorAdapter myCursorAdaptor = new SimpleCursorAdapter(this, R.layout.item_layout, null, fromFieldNames, toViewIDS, 0);
// Set adaptor for listView
myList.setAdapter(myCursorAdaptor);
Picasso
.with(getApplicationContext())
.load("http://www.newton.ac.uk/files/covers/968361.jpg")
.resize(600, 200) // resizes the image to these dimensions (in pixel). does not respect aspect ratio
.into(img);
new AsyncTask<SimpleCursorAdapter, Void, Cursor>() {
private SimpleCursorAdapter mSimpleCursorAdapter;
@Override
protected Cursor doInBackground(SimpleCursorAdapter... params) {
// Save cursorAdapter to use in postExecute
this.mSimpleCursorAdapter = params[0];
// Load cursor on background thread with search function
return myDb.ViewAll();
}
}
@Override
protected void onPostExecute(Cursor cursor) {
super.onPostExecute(cursor);
// and update the cursor (which is already in the listview)
this.mSimpleCursorAdapter.changeCursor(cursor);
}
}.execute(myCursorAdaptor);
}
private void registerListClickCallback() {
myList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View viewClicked, int position, long IDinDB) {
Cursor res = myDb.GetRow(IDinDB);
if (res.moveToFirst()) {
long idDB = res.getLong(DatabaseHelper.ROWID);
String message = "ID: " + idDB;
//Toast.makeText(ViewActivity.this, message, Toast.LENGTH_LONG).show();
String hello = Long.toString(idDB);
Intent intent = new Intent(ViewActivity.this, ImageFullViewActivity.class);
intent.putExtra("ImgID", hello);
startActivity(intent);
}
}
});
}
如何解决此问题。 此外,图像的网址只是暂时的,因为我正在使用它进行测试。我能否在.load()?
中插入图像的真实路径由于