왜 나는지 모르겠습니다 ㅜㅜ ProgressDialog 뜨다가 로딩못하고 팅기네요.
getStringExtra로 String contenturl 을 받아오는것까진 됬습니다. 출력도 됬구요.
그리고 contenturl을 탐색해서 content를 추출하고 싶은데.... 여기서부터 안되네요 ㅜㅜ
의심되는 부분이 몇군데 있는데..
처음엔 " content = tr.get(0).select("td").text(); " 부분이 문제인가 싶어서 그부분만 지우고 돌려봐도 여전히 똑같은 에러가 뜹니다.
txtcontent.setText(content); 도 postexecute에서 하는게 좋다고 해서 그쪽으로도 옮겨봤는데.. 그대로네요.
아니면 new JsoupContentView().execute(); 자체에 문제가 있는지 모르겠습니다... 일단 이부분 지우면 에러는 확실히 안생기네요 ..
조언 부탁드립니다 !!!
-------------------------------------------------------------------
package com.example.tabviewtest;
import java.io.IOException;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.widget.TextView;
public class SingleItemView extends Activity {
// Declare Variables
String num;
String title;
String date;
String position;
String contenturl;
// String content;
ProgressDialog mProgressDialog;
Element temps;
String temp;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Get the view from singleitemview.xml
setContentView(R.layout.singleitemview);
Intent i = getIntent();
// Get the result of rank
num = i.getStringExtra("num");
// Get the result of country
title = i.getStringExtra("title");
// Get the result of population
date = i.getStringExtra("date");
contenturl = i.getStringExtra("contenturl");
new JsoupContentView().execute();
// Locate the TextViews in singleitemview.xml
TextView txtnum = (TextView) findViewById(R.id.num);
TextView txttitle = (TextView) findViewById(R.id.title);
TextView txtdate = (TextView) findViewById(R.id.date);
// TextView txtcontent = (TextView) findViewById(R.id.content);
// Set results to the TextViews
txtnum.setText(num);
txttitle.setText(title);
txtdate.setText(date);
// txtcontent.setText(content);
// Capture position and set results to the ImageView
}
///////////////파싱 도전!!!/////////////////////
// Content AsyncTask
private class JsoupContentView extends AsyncTask<Void,Void, Void> {
String content;
@Override
protected void onPreExecute() {
super.onPreExecute();
// Create a progressdialog
mProgressDialog = new ProgressDialog(SingleItemView.this);
// Set progressdialog title
mProgressDialog.setTitle("내용");
// Set progressdialog message
mProgressDialog.setMessage("Loading...");
mProgressDialog.setIndeterminate(false);
// Show progressdialog
mProgressDialog.show();
}
@Override
protected Void doInBackground(Void... parms) {
try {
// Connect to the Website URL
Document doc = Jsoup.connect(contenturl).get();
Elements table = doc.select("table[class=boardlist_type1]");
Elements tbody = table.select("tbody");
Elements tr = tbody.get(1).select("tr");
// Elements tds = tr.get(0).select("td");
content = tr.get(0).select("td").text();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(Void result) {
TextView txtcontent = (TextView) findViewById(R.id.content);
txtcontent.setText(content);
mProgressDialog.dismiss();
}
}
}