本帖最后由 u013514338 于 2014-04-16 03:12:58 编辑

解决方案 »

  1.   

    没找到Jsoup这个包,重新导入试试
      

  2.   


    您是说onClick这个按钮的代码吗?
    <Button
                android:id="@+id/set"
                android:layout_width="100dp"
                android:layout_height="wrap_content"
                android:onClick="getFile"
                android:text="@string/set" />就是我贴出来的那段
      

  3.   


    我一开始引用了
    jsoup-1.7.3-javadoc.jar
    jsoup-1.7.3-sources.jar
    jsoup-1.7.3.jar然后我删掉      jsoup-1.7.3-sources.jar
    并在 java build path -->  order and export 里面勾选了相应jar文件之后就好了(如图)! 谢谢~!
          
      

  4.   


    //onClick getFile
            public void getFile(View view)  {
                File input;
                TextView coursesList  = (TextView) findViewById(R.id.theList);
                TextView location = (TextView) findViewById(R.id.location);
                filePath = location.getText().toString();
             
                if(fileIsExists(filePath)){
                     
                    input = new File(filePath);               
                    try {
                        //parse the html file
                        Document doc;
                        Course course = new Course();
                        doc = Jsoup.parse(input, "UTF-8"); //经测试后,我认为是这句引起的程序崩溃
                        Elements links = doc.getElementsByAttributeValue("ALIGN","left");
                        int i = 0;
                        boolean needrecord = false;//in order to find the information needed
     
                        for (Element link : links) {//setText on the screen and save the information as a file
                              String linkText = link.text();
                              if(linkText.equals("EE")){//after String EE found, the course name, date, and instructor
                                  needrecord = true;    //can be found in the fixed position
                              }
                              if(needrecord){
                                  i++;
                                  if(i == 4){//course name
                                        coursesList.setText(linkText+"       ");
                                  }
                                  if(i == 5){//date
                                        coursesList.setText(linkText+"      ");
                                  }
                                  if(i == 8){//instructor
                                        coursesList.setText(linkText+"   \n");
                                        needrecord = false;
                                        i = 0;
                                  }
                              }
                        }
                                        flage = true;  
                    } catch (IOException e) {
                        // TODO Auto-generated catch block
                        coursesList.setText("ERROR!"+e.toString());
                        e.printStackTrace();
                     
                    }           
                                  }//if
                 
                else{
                    coursesList.setText("File path is not right. Check the path and retype the path.");
                }
     
            }
    问题已经解决了  谢谢~
      

  5.   

    终于让我找到这个帖子了!在布局文件中为标签绑定事件处理方法我总是出现这个问题,这个问题的原因是不是因为缺少jsoup这个包来在XML文件中解析然后就找不到所绑定的方法?怎么添加jsoup?是另外下载的吗?