Java Android listview的应用程序引擎数据存储
我已经在我的应用程序引擎后端设置了一个基本实体类Java Android listview的应用程序引擎数据存储,java,android,eclipse,google-app-engine,google-cloud-endpoints,Java,Android,Eclipse,Google App Engine,Google Cloud Endpoints,我已经在我的应用程序引擎后端设置了一个基本实体类 `@Entity` `public class Club {` `@Id` `private int id;` `private String clubName;` `public Club() {` `}` `public int getId() {` `return id;` `}` `public void setId(int id){ this.id =id; }` `
`@Entity`
`public class Club {`
`@Id`
`private int id;`
`private String clubName;`
`public Club() {`
`}`
`public int getId() {`
`return id;`
`}`
`public void setId(int id){
this.id =id;
}`
`public String getClubName() {
return clubName;
}`
`public void setClubName(String clubName) {
this.clubName = clubName;
}
}`
我已经生成了云端点类和云端点库。
我希望能够将数据存储中的clubName填充到android中的listview中,但不确定如何做到这一点。
我正试图遵循这一点,但到目前为止,我无法理解该怎么做。我是新手,如果有人能给我指引正确的方向,我将不胜感激。您可以使用以下步骤来实现您的目标: 1,正如google文档中提到的在android中使用云端点,通过添加所需的库和进行API调用来准备应用程序,然后从后端获取数据,您可以将该数据存储到SQL数据库中。可以在异步任务的onpostexecute方法中执行此步骤
protected void onPostExecute(ScoreCollection scores) {
// Do something with the result. maybe the store the data to sqlite database
}
}
要了解如何在SQLITe数据库中存储数据,请参阅
2,现在将SQLITE db中的数据查询到a中,然后使用a在布局或活动屏幕中的a上显示光标中的数据
一段大致的代码将包含如下步骤:
yourcursor = yourdatabase.query; //this is the cursor returned from querying your db
adapter = new SimpleCursorAdapter(this.getActivity(), R.layout.onerowinalistview, yourcursor, FROM, TO,0); // this connects the columns of your DB mentioned in FROM array to the elements in a row of your list as mentioned in TO array
ListView yourlistview = (ListView) view.findViewById(R.id.yourlistview);//this is the listview element in your screen layout
yourlistview.setAdapter(adapter); // setting the adapter to the listview
希望这有帮助