gpt4 book ai didi

android - ParseQueryAdapter,不显示结果

转载 作者:行者123 更新时间:2023-11-29 01:33:28 26 4
gpt4 key购买 nike

我正在尝试在我的项目中使用 ParseQueryAdapter,但没有任何运气显示结果。

我的目标是从 ParseUser 获取数据。所以,我的模型正在扩展 ParseUser:

所以我有一个模型:

@ParseClassName("Midwifefirm")
public class Midwifefirm extends ParseUser {



public Midwifefirm() {
// A default constructor is required.
}

//practice name
public String getPracticeName() {
return getString("practicename");
}

public void setPracticeName(String title) {
put("title", title);
}

//education

public String getEducation() {
return getString("education");
}

public void setEducation(String education) {
put("education", education);
}

//years in practice

public String getYearsinPractice() {
return getString("yearsinpractice");
}

public void setYearsinPractice(String yearsinpractice) {
put("yearsinpractice", yearsinpractice);
}

//practice philosophy

public String getPracticePhilosophy() {
return getString("practicephilosophy");
}

public void setPracticePhilosophy(String practicephilosophy) {
put("practicephilosophy", practicephilosophy);
}

适配器在这里;我认为问题可能出在我的查询上:

public class CustomMidwifeAdapter extends ParseQueryAdapter<Midwifefirm> {


public CustomMidwifeAdapter(Context context) {
//query using Midwifefirm class, to get list of midwives
super(context, new ParseQueryAdapter.QueryFactory<Midwifefirm>() {
public ParseQuery<Midwifefirm> create() {

ParseQuery query = new ParseQuery("Midwifefirm");
query.whereEqualTo("userType", "midwife");


return query;

}


});

}

@Override
public View getItemView(Midwifefirm midwifefirm, View view, ViewGroup parent) {

if (view == null) {
view = View.inflate(getContext(), R.layout.activity_midwife_result_list, null);

}

//use midwifefirm as item view/list

super.getItemView(midwifefirm, view, parent);


// find in layout the practice name
TextView titleTextView = (TextView) view.findViewById(R.id.practicename);

//in the midwifefirm data model, call getPracticename
titleTextView.setText(midwifefirm.getPracticeName());

// Add education view
TextView EducationView = (TextView) view.findViewById(R.id.education);

EducationView.setText(midwifefirm.getEducation());

// Add yearsexperience view
TextView ExperienceView = (TextView) view.findViewById(R.id.yearsinpractice);
ExperienceView.setText(midwifefirm.getYearsinPractice());

//Add practice philosophy view
TextView PracticePhilosophyView = (TextView) view.findViewById(R.id.practicephilosophy);
PracticePhilosophyView.setText(midwifefirm.getPracticePhilosophy());


return view;
}

}

这是我的 ListView;

public class MidwifeResultList extends ListActivity {


private ParseQueryAdapter<Midwifefirm> mainAdapter;

private CustomMidwifeAdapter midwifeListAdapter;



@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

//set display to listview, empty
getListView().setClickable(false);




//initialize main ParseQueryAdapter
mainAdapter = new ParseQueryAdapter<Midwifefirm>(this, Midwifefirm.class);
mainAdapter.setTextKey("practicename");
mainAdapter.setTextKey("education");
mainAdapter.setTextKey("yearsinpractice");
mainAdapter.setTextKey("practicephilosophy");


// Initialize the subclass of ParseQueryAdapter
midwifeListAdapter = new CustomMidwifeAdapter(this);


setListAdapter(mainAdapter);

// Initialize ListView and set initial view to mainAdapter
// listView = (ListView) findViewById(R.id.lvMidwives);
// listView.setAdapter(mainAdapter);
// mainAdapter.loadObjects();

}





}

我可能设置错了..感谢任何见解。

最佳答案

仅从您提供的内容来看,我认为这与您的查询有关。您正在查询键“userType”,但您的子类 Midwifefirm 似乎没有该键。

编辑

要回答您的评论,您将使用如下查询获取所有 Midwife 对象:

ParseQuery<Midwifefirm> query = ParseQuery.getQuery(Midwifefirm.class); 
/* add any additional constraints to your query here */
query.findInBackground(new FindCallback<Midwifefirm>() {
@Override
public void done(List<Midwifefirm> results, ParseException e) {

}
}

我相信 Parse 对您可以通过单个查询获得的对象数量有 100 个限制,因此您可能需要寻找可以增加该数量以满足您需求的方法。

关于android - ParseQueryAdapter,不显示结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29974952/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com