-1
我遇到了我的Android應用程序中的一個問題,我無法從網站獲取特定數據。我的應用程序崩潰。這裏是我的代碼:無法從網站獲取數據
private void AddListenerOnButton() {
spinner = (Spinner) getView().findViewById(R.id.spinner);
final WebView webView = (WebView) getView().findViewById(R.id.webView1);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setRenderPriority(RenderPriority.HIGH);
webView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
webView.getSettings().setDatabaseEnabled(true);
webView.getSettings().setDomStorageEnabled(true);
webView.getSettings().setAppCacheEnabled(true);
webView.getSettings().setBuiltInZoomControls(true);
spinner.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) {
String text1 = spinner.getSelectedItem().toString().trim();
//WebClient wc = new WebClient();
if (text1.equals("US Dollar - USD")) {
try {
Document doc = Jsoup.connect("http://en.wikipedia.org/").get();
Elements newsHeadlines = doc.select("#mp-itn b a");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
這裏是我的logcat:
07-09 23:04:52.161: E/AndroidRuntime(798): FATAL EXCEPTION: main
07-09 23:04:52.161: E/AndroidRuntime(798): java.lang.NoClassDefFoundError: org.jsoup.Jsoup
07-09 23:04:52.161: E/AndroidRuntime(798): at com.example.currencyconverter.Fragment2$1.onItemSelected(Fragment2.java:77)
07-09 23:04:52.161: E/AndroidRuntime(798): at android.widget.AdapterView.fireOnSelected(AdapterView.java:892)
07-09 23:04:52.161: E/AndroidRuntime(798): at android.widget.AdapterView.access$200(AdapterView.java:49)
07-09 23:04:52.161: E/AndroidRuntime(798): at android.widget.AdapterView$SelectionNotifier.run(AdapterView.java:860)
07-09 23:04:52.161: E/AndroidRuntime(798): at android.os.Handler.handleCallback(Handler.java:725)
07-09 23:04:52.161: E/AndroidRuntime(798): at android.os.Handler.dispatchMessage(Handler.java:92)
07-09 23:04:52.161: E/AndroidRuntime(798): at android.os.Looper.loop(Looper.java:137)
07-09 23:04:52.161: E/AndroidRuntime(798): at android.app.ActivityThread.main(ActivityThread.java:5041)
07-09 23:04:52.161: E/AndroidRuntime(798): at java.lang.reflect.Method.invokeNative(Native Method)
07-09 23:04:52.161: E/AndroidRuntime(798): at java.lang.reflect.Method.invoke(Method.java:511)
07-09 23:04:52.161: E/AndroidRuntime(798): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
07-09 23:04:52.161: E/AndroidRuntime(798): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
07-09 23:04:52.161: E/AndroidRuntime(798): at dalvik.system.NativeStart.main(Native Method)
這到底是怎麼回事?我似乎無法理解發生了什麼。任何幫助將不勝感激。