1

我一直在通過帖子排序試圖找出這一點。我不能讓我的Android形式的應用程序發佈到谷歌文檔的電子表格,尋求幫助,可有人請看看通過編碼,並告訴我,如果我錯過了一些東西我在做什麼錯在這裏是代碼:Android應用程序Google電子表格數據文件

import java.io.IOException; 
import java.io.InputStream; 
import java.io.UnsupportedEncodingException; 
import java.net.URL; 

import java.util.ArrayList; 
import java.util.List; 


import org.apache.http.HttpEntity; 
import org.apache.http.HttpResponse; 
import org.apache.http.NameValuePair; 
import org.apache.http.client.ClientProtocolException; 
import org.apache.http.client.HttpClient; 
import org.apache.http.client.entity.UrlEncodedFormEntity; 
import org.apache.http.client.methods.HttpPost; 
import org.apache.http.impl.client.DefaultHttpClient; 
import org.apache.http.message.BasicNameValuePair; 


import android.os.AsyncTask; 
import android.util.Log; 
import android.view.View; 
import android.view.View.OnClickListener; 
import android.widget.Button; 
import android.widget.EditText; 
import android.widget.Spinner; 

public class SubmitForm extends AsyncTask<URL, Object, Object> implements OnClickListener{ 

EditText arrivalText; 
EditText assignmentText; 
EditText clientText; 
EditText departureText; 
Spinner employeeSpinner; 
EditText jobDateText; 
Spinner jobTypeSpinner; 
EditText notesText; 
Button submitButton; 

List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(3); 

public void onClick(View v) { 
    // TODO Auto-generated method stub 
    HttpClient httpclient = new DefaultHttpClient(); 
    HttpPost httppost = new HttpPost("https://docs.google.com/spreadsheet/ccc?key=0AsEKRuGCDAg_dE01ZXlyR2VoTHFrWUdTNUVwdnN0R0E#gid=0"); 

    try{ 
     nameValuePairs.add(new BasicNameValuePair("entry.0.single", 
       employeeSpinner.getSelectedItem().toString())); 
     nameValuePairs.add(new BasicNameValuePair("entry.1.single", 
       jobTypeSpinner.getSelectedItem().toString())); 
     nameValuePairs.add(new BasicNameValuePair("entry.2.single", 
       clientText.getText().toString())); 
     HttpResponse response = httpclient.execute(httppost); 
     Log.d("RESPONSE", "info: "); 
     HttpEntity entity = response.getEntity(); 
     InputStream inputstream = entity.getContent(); 
     httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); 


    } catch (UnsupportedEncodingException e) { 
     // TODO Auto-generated catch block 
     Log.d("YOUR_TAG", "An error has occurred", e); 
     e.printStackTrace(); 
    } catch (ClientProtocolException e) { 
     // TODO Auto-generated catch block 
     Log.d("YOUR_TAG", "client protocol exception", e); 
     e.printStackTrace(); 
    } catch (IOException e) { 
     // TODO Auto-generated catch block 
     Log.d("YOUR_TAG", "io exception", e); 
     e.printStackTrace(); 
    } finally { 
    } 
} 

protected Object doInBackground(URL... params) { 
    // TODO Auto-generated method stub 
    return null; 
} 
} 

logcat的:

10-29 20:03:44.583: D/CLIPBOARD(28779): Hide Clipboard dialog at Starting input: finished by someone else... ! 
10-29 20:03:57.636: W/dalvikvm(28779): threadid=1: thread exiting with uncaught exception (group=0x40bef1f8) 
10-29 20:03:57.646: E/AndroidRuntime(28779): FATAL EXCEPTION: main 
10-29 20:03:57.646: E/AndroidRuntime(28779): java.lang.IllegalStateException: Could not find a method onClick(View) in the activity class com.matrixapps.assignmenttracker.AssignmentTracker for onClick handler on view class android.widget.Button with id 'submitButton' 
10-29 20:03:57.646: E/AndroidRuntime(28779): at android.view.View$1.onClick(View.java:3087) 
10-29 20:03:57.646: E/AndroidRuntime(28779): at android.view.View.performClick(View.java:3627) 
10-29 20:03:57.646: E/AndroidRuntime(28779): at android.view.View$PerformClick.run(View.java:14329) 
10-29 20:03:57.646: E/AndroidRuntime(28779): at android.os.Handler.handleCallback(Handler.java:605) 
10-29 20:03:57.646: E/AndroidRuntime(28779): at android.os.Handler.dispatchMessage(Handler.java:92) 
10-29 20:03:57.646: E/AndroidRuntime(28779): at android.os.Looper.loop(Looper.java:137) 
10-29 20:03:57.646: E/AndroidRuntime(28779): at android.app.ActivityThread.main(ActivityThread.java:4511) 
10-29 20:03:57.646: E/AndroidRuntime(28779): at java.lang.reflect.Method.invokeNative(Native Method) 
10-29 20:03:57.646: E/AndroidRuntime(28779): at java.lang.reflect.Method.invoke(Method.java:511) 
10-29 20:03:57.646: E/AndroidRuntime(28779): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:976) 
10-29 20:03:57.646: E/AndroidRuntime(28779): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:743) 
10-29 20:03:57.646: E/AndroidRuntime(28779): at dalvik.system.NativeStart.main(Native Method) 
10-29 20:03:57.646: E/AndroidRuntime(28779): Caused by: java.lang.NoSuchMethodException: onClick [class android.view.View] 
10-29 20:03:57.646: E/AndroidRuntime(28779): at java.lang.Class.getConstructorOrMethod(Class.java:460) 
10-29 20:03:57.646: E/AndroidRuntime(28779): at java.lang.Class.getMethod(Class.java:915) 
10-29 20:03:57.646: E/AndroidRuntime(28779): at android.view.View$1.onClick(View.java:3080) 
10-29 20:03:57.646: E/AndroidRuntime(28779): ... 11 more 
+0

問題是什麼?你的應用崩潰了?你正在使用哪個android操作系統? –

+0

是的,它崩潰我目前正在測試4.0.3和4.1我嘗試了異步方法,但仍然崩潰。有什麼建議麼? –

+0

發佈您使用'AsyncTask'的代碼。和崩潰日誌。 –

回答

0

這是爲時已晚,但它可能會幫助別人試圖做類似的事情,this文章CodeSmith中的細節,你應該使用將數據從Android應用程序發送到谷歌電子表格的過程。

+0

雖然這個鏈接可能回答這個問題,但最好在這裏包含答案的重要部分並提供參考鏈接。如果鏈接頁面更改,則僅鏈接答案可能會失效。 [爲什麼以及如何刪除一些答案?](http://stackoverflow.com/help/deleted-answers) – bummi

相關問題