-4
訪問我得到了下面的錯誤錯誤:Listitem(String,String)在Listitem中不公開;不能從外面包
Error:(91, 37) error: Listitem(String,String) is not public in Listitem; cannot be accessed from outside package
我有2個包
這是Listitem.java
public class Listitem implements Parcelable {
String id;
//String name;
String url;
Listitem(Parcel in){
this.id = in.readString();
// this.name = in.readString();
this.url = in.readString();
}
Listitem(String name, String url) {
this.id = id;
this.url = url;
}
@Override
public int describeContents() {
return 0;
}
public void setUrl(String url) {
this.url = url;
}
public String getUrl() {
return url;
}
public void setId(String id) {
this.id = id;
}
public String getId() {
return id;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(this.id);
// dest.writeString(this.name);
dest.writeString(this.url);
}
public static final Parcelable.Creator<Listitem> CREATOR = new Parcelable.Creator<Listitem>() {
public Listitem createFromParcel(Parcel in) {
return new Listitem(in);
}
public Listitem[] newArray(int size) {
return new Listitem[size];
}
};
}
數據庫處理器
List<Listitem> Objectslist = new ArrayList<Listitem>();
SQLiteDatabase db = this.getWritableDatabase();
String selectQuery = "SELECT "+OBJECT_ID+" ,"+OBJECT_NAME+" ,"+OBJECT_URL +" FROM " + TABLE_OBJECTS;
Cursor cursor = db.rawQuery(selectQuery, null);
DatabaseUtils.dumpCursorToString(cursor);
// looping through all rows and adding to list
if (cursor.moveToFirst()) {
do {
Listitem object = new Listitem("1","b");
爲什麼我得到錯誤?已經Listitem是公開的,我錯過了什麼?
哦,我嘗試添加公共的parcelable不是構造函數謝謝 – Moudiz