![](/img/trans.png)
[英]How to correctly retrieve int from a Google App Engine datastore (Java)?
[英]how to retrieve info from datastore using google app engine and display it in a list view on an android app using java?
我正在嘗試制作一個Android應用程序,從谷歌應用程序引擎數據存儲區檢索信息,並在Android應用程序中顯示為列表視圖..任何人都可以幫我解決一些代碼或解釋為此目的究竟需要做什么? 我已經在服務器端進行了修改,以便在數據存儲上存儲數據..我不知道如何將數據存入android應用程序..我正在使用eclipse indigo和語言是java
編輯:我正在使用我的代碼,我正在使用從數據存儲區檢索一組字符串並將其放在列表視圖中......代碼看起來都是亂七八糟但我要求你忍受我並解釋如何寫它...當我到達應該顯示這個檢索到的字符串列表的頁面時,當前應用程序強制關閉...
public class Display extends ListActivity
{
private LayoutInflater mInflater;
private Vector<RowData> data;
RowData rd;
static String[] title;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.displaylayout);
MyRequestFactory factory = (MyRequestFactory)Util.getRequestFactory(Display.this,MyRequestFactory.class);
FebfourthRequest febfourthRequest = factory.febfourthRequest();
final List<TrialDBProxy> list= new ArrayList<TrialDBProxy>();
febfourthRequest.queryTrialDBs().fire(new Receiver<List<TrialDBProxy>>()
{
@Override
public void onSuccess(List<TrialDBProxy> arg0) {
// TODO Auto-generated method stub
list.addAll(arg0);
}
});
for(int i=0;i<list.size();i++)
{
title[i] = list.get(i).getMessage();
}
mInflater = (LayoutInflater) getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
data = new Vector<RowData>();
for(int i=0;i<title.length;i++)
{
rd = new RowData(i,title[i]);
data.add(rd);
}
int[] to = new int[] { R.id.text1, R.id.text2 };
@SuppressWarnings("deprecation")
Cursor mCursor = this.getContentResolver().query(People.CONTENT_URI, null, null, null, null);
ListAdapter adapter = new SimpleCursorAdapter(this,R.layout.displaylayout,mCursor,title,to);
setListAdapter(adapter);
getListView().setTextFilterEnabled(true);
}
private class RowData
{
protected int mId;
protected String mTitle;
RowData(int id,String title)
{
mId=id;
mTitle = title;
}
@Override
public String toString()
{
return mId+" "+mTitle;
}
} '
注意:TrialDB是包含我要存儲在數據存儲區中的所有字段的文件。 displaylayout是我創建了listview的xml文件。 我猜測我必須把代碼用於顯示東西的主要部分是在onCreate()方法中。 請幫忙 !
這已經是學習 Google App Engine和Android開發的一個非常好的起點 。
我可以寫下以下步驟 :
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.