我在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)
这里发生了什么?我似乎无法理解发生了什么。我一直在谷歌搜索一周。任何帮助将不胜感激。