Android アプリケーションで、Web サイトから特定のデータを取得できないという問題が発生しました。アプリがクラッシュします。これが私のコードです:
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)
ここで何が起きてるの?何が起こっているのか理解できないようです。Google で 1 週間検索しています。どんな助けでも大歓迎です。