2014-04-24 35 views
1

基本上即時通訊即時嘗試建立一個Android應用程序,顯示從我的校園巴士的時間表..問題是我無處保存我的數據..我可以保存我的數據從我的直接形成谷歌文檔電子表格..如果是的話怎麼樣? 我對形式Android表單提交直接到谷歌文檔

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="fill_parent" 
android:layout_height="match_parent" 
android:orientation="vertical" 
tools:context=".MainActivity51" > 

<TextView 
    android:id="@+id/textView1" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_margin="10dp" 
    android:gravity="center_horizontal" 
    android:text="@string/Outpass" 
    android:textAppearance="?android:attr/textAppearanceLarge" 
    android:textSize="28sp" /> 

<TextView 
    android:id="@+id/textView5" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignLeft="@+id/textView1" 
    android:layout_below="@+id/editText3" 
    android:layout_marginLeft="10dp" 
    android:text="@string/Bus" 
    android:textAppearance="?android:attr/textAppearanceMedium" 
    android:textSize="22sp" /> 

<EditText 
    android:id="@+id/editText3" 
    android:layout_width="180dp" 
    android:layout_height="wrap_content" 
    android:layout_alignLeft="@+id/editText2" 
    android:layout_alignParentRight="true" 
    android:layout_below="@+id/editText2" 
    android:layout_marginRight="10dp" 
    android:layout_marginTop="16dp" 
    android:ems="15" 
    android:inputType="number" > 
</EditText> 

<EditText 
    android:id="@+id/editText2" 
    android:layout_width="180dp" 
    android:layout_height="wrap_content" 
    android:layout_alignLeft="@+id/editText1" 
    android:layout_below="@+id/editText1" 
    android:layout_marginTop="14dp" 
    android:ems="15" 
    android:inputType="number" /> 

<TextView 
    android:id="@+id/textView4" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignBaseline="@+id/editText3" 
    android:layout_alignBottom="@+id/editText3" 
    android:layout_alignRight="@+id/textView5" 
    android:layout_marginLeft="10dp" 
    android:text="@string/Room" 
    android:textAppearance="?android:attr/textAppearanceMedium" 
    android:textSize="22sp" /> 

<EditText 
    android:id="@+id/editText1" 
    android:layout_width="180dp" 
    android:layout_height="wrap_content" 
    android:layout_alignBottom="@+id/textView2" 
    android:layout_alignRight="@+id/textView1" 
    android:ems="10" 
    android:inputType="textPersonName" /> 

<TextView 
    android:id="@+id/textView2" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignLeft="@+id/textView1" 
    android:layout_below="@+id/textView1" 
    android:layout_marginLeft="10dp" 
    android:layout_marginTop="58dp" 
    android:text="@string/Name" 
    android:textAppearance="?android:attr/textAppearanceMedium" 
    android:textSize="22sp" /> 

<TextView 
    android:id="@+id/textView3" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignBaseline="@+id/editText2" 
    android:layout_alignBottom="@+id/editText2" 
    android:layout_alignLeft="@+id/textView2" 
    android:text="@string/ID" 
    android:textAppearance="?android:attr/textAppearanceMedium" 
    android:textSize="22sp" /> 

<TextView 
    android:id="@+id/textView6" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignBottom="@+id/textView5" 
    android:layout_alignLeft="@+id/button1" 
    android:layout_marginLeft="16dp" 
    android:text="@string/Time2" 
    android:textAppearance="?android:attr/textAppearanceMedium" /> 

<Button 
    android:id="@+id/button1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_below="@+id/textView5" 
    android:layout_marginTop="48dp" 
    android:layout_toRightOf="@+id/textView5" 
    android:text="@string/Save" /> 

XML代碼現在我想從上面的字段我的數據應該得到直接保存在谷歌文檔電子表格上按鈕的onclick。 java代碼: package com.example.sbapis1;

 import android.app.Activity; 
    import android.os.Bundle; 

     public class MainActivity51 extends Activity { 
    @Override 
    protected void onCreate(Bundle savedInstanceState){ 
    super.onCreate(savedInstanceState); 
setContentView(R.layout.activity_main_activity41); 

} 

    } 

回答

0

不知道你在做什麼。您是否試圖從您的應用程序或Google Doc Spreadsheet中查看時間表?

如果您只是讓這個電子表格爲您的應用程序提供內容,那麼使用SQLite實現可能會更好。

如果你想要谷歌電子表格,你將不得不使用GData庫和可能的某種谷歌身份驗證(除非你不介意把你的用戶名和密碼直接放入你的應用程序,我不會介意推薦)。這是很多解釋和顯示在一個職位的代碼,但你可以看看這個資源:https://github.com/gregriggins36/to-google-spreadsheet