0
我想查詢解析數據庫並得到錯誤:無法解析符號'FindCallBack'。 我試過使用'query.find',但我被告知'findInBackground'更有效。 主要目標是查詢信息並迭代列表以供將來使用。 當我使用'query.find'時,查詢本身起作用,但迭代失敗,就像我試圖訪問無效字段一樣。Android解析 - 無法解析符號'FindCallBack'
'FindCallBack' 版本
import com.parse.Parse;
import com.parse.ParseObject;
import com.parse.ParseQuery;
import com.parse.SaveCallback;
import com.parse.ParseException;
import com.parse.FindCallback;
import java.util.Calendar;
import java.util.Date;
import java.text.SimpleDateFormat;
import java.util.List;
public class ListNodeActivity extends AppCompatActivity
{
private Task t = new Task();
private Spinner spin;
private Spinner empolyeeSpinner;
private int task_id=1;
private String time_Date_str = null;
private Locations returned_selc_loc;
private EditText loc;
private ParseObject parse_task=null;
private DBManager dbm;
private static final int ACTIVITY_SELECT_LOCATION = 0;
private ParseObject team_members = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_list_node);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
//check is username & password exist
ParseQuery<ParseObject> query = new ParseQuery<ParseObject>("OTSUser");
query.whereContains("TeamName", Globals.team_name);
query.whereEqualTo("IsManager",0);
query.findInBackground(new FindCallBack<ParseObject>() {
public void done(List<ParseObject> usrs;ParseException e) {
if (e == null) {
for (int i = 0; i < usrs.size(); i++) {
Log.w("debug", usrs.get(i).getString("Userame"));
}
} else {//handle the error
}
}
});
}
}
'query.find' 版本
//check is username & password exist
ParseQuery<ParseObject> query = new ParseQuery<ParseObject>("OTSUser");
query.whereContains("TeamName", Globals.team_name);
query.whereEqualTo("IsManager",0);
List<ParseObject> usrs=null;
try {
usrs = query.find();
Log.w("debug","size of usrs "+usrs.size());
for (int i = 0; i < usrs.size(); i++)
{
// empolyeeSpinnerAdapter.add(usrs.get(i).getString("Userame"));
Log.w("debug",usrs.get(i).getString("Userame"));
}
} catch (ParseException e) {}
不能相信我錯過了。謝謝。 –