解决方案 »
- 怎么修改Android源码图库Gallery2的背景
- android问题 高分 高手进
- listView点击一个item项以后,刷新数据回来以后,显示item不发生错位?
- 写在 “记录我的android开发经历”之前
- android不显示app_name和实现加载提示,在线等
- android NDK编译本地代码出的问题,求教
- 关于窗体刷新:如果只想刷新背景图片,但是上面有Button等控件,会被刷没了?
- [求助]如何获得googlemap两点之间线路上所有点的经纬度值
- 请问关于使用fragment做底部菜单,不能切换的问题
- android A 界面的recycleview中的item 点击跳转至B界面,然后选中B界面的item回到A界面给被点击的item赋值
- 关于自定义view(画板)手势监听的问题
- 如何监听耳机按键广播
您是说onClick这个按钮的代码吗?
<Button
android:id="@+id/set"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:onClick="getFile"
android:text="@string/set" />就是我贴出来的那段
我一开始引用了
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文件之后就好了(如图)! 谢谢~!
//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.");
}
}
问题已经解决了 谢谢~