첨부한 그림에서 빨간 네모친것 위치보기 버튼을 누르면 다른 액티비티로 넘어가게 하고싶은데
아무리 해도 안되네요 ㅜㅜ; 아래 코드 올릴테니까 어떻게 하면 좋을지... 조언좀여ㅠㅠㅠ
내일 발표해야 되는데. 안되네요.... ㅠㅠ
search_res.java
public class search_res extends Activity{
ArrayList<HashMap<String, String>> data;
ListView list;
TextView title, writer, company, position;
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
Intent i = getIntent();
String search = i.getExtras().getString("search").toString();
TextView kwd = (TextView) findViewById(R.id.search);
setContentView(R.layout.search_list1);
if(search.length()<1)
{
Toast.makeText(getApplicationContext(), "도서명, 저자 또는 출판사를 입력해주세요.", Toast.LENGTH_SHORT).show();
}else{
data = new ArrayList<HashMap<String, String>>();
try {
builPostList(search);
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
list = (ListView) findViewById(R.id.listView1);
SimpleAdapter sa = new SimpleAdapter(this, data, R.layout.search_list2, new String[] {"title", "writer", "company", "position"}, new int[]{R.id.title, R.id.writer, R.id.company, R.id.position});
list.setAdapter(sa);
}
}
private void builPostList(String search) throws MalformedURLException, IOException
{
String surl = "http://library.skhu.ac.kr/DLiWeb20/components/searchir/result.aspx?m_var=421&srv_id=31&qy_frm=QUICK&adf=&adt=&cl_id=ALL&rid_all=&st_f=&st_o=&pg=1&rpp=20&mc=300&dp_op=LIST&t_path=&qy_typ=KEYWORD&brch=ALL&qy_idx=TITL&qy_kwd="
+ URLEncoder.encode(search, "UTF-8");
String nurl = null;
try{
//nurl = URLEncoder.encode(surl, "UTF-8");
//URL url = new URL("nurl);
URL url = new URL("surl);
data.clear();
InputStream html = url.openStream();
Source source = new Source(new InputStreamReader(html,"UTF-8"));
source.fullSequentialParse();
Element table = (Element) source.getAllElements(HTMLElementName.TABLE).get(28);
List<Element> trtag = table.getAllElements(HTMLElementName.TR);
for(int i=1; i<trtag.size(); i+=2)
{
Element tr = (Element) trtag.get(i);
if (tr.getAllElements(HTMLElementName.TD).size() < 2)
continue;
Element td = (Element) tr.getAllElements(HTMLElementName.TD).get(1);
List<Element> sp = td.getAllElements(HTMLElementName.SPAN);
//占쌩곤옙
HashMap<String, String> hm = new HashMap<String, String>();
for(Iterator it = sp.iterator(); it.hasNext();)
{
Element le = (Element) it.next();
//HashMap<String, String> hm = null;
String c = le.getAttributeValue("class");
String t = le.getAttributeValue("title");
String v = le.getContent().toString();//le.getAttributeValue("value");
if(v == null)
{
continue;
}
if(c != null && c.equals("result_title"))
{
String value = le.getContent().toString();//le.getAttributeValue("value").toString();
TextView tv = new TextView(this);
tv.setText(Html.fromHtml(value));
hm.put("title", "도서명 : " + tv.getText().toString());
}
if (t == null)
continue;
if(t.equals("저자"))
{
String value = le.getContent().toString();//le.getAttributeValue("value").toString();
hm.put("writer", "저자 : " + value);
//data.add(hm);
}
if(t.equals("출판사"))
{
String value = le.getContent().toString();//le.getAttributeValue("value").toString();
hm.put("company", "출판사 : " + value);
//data.add(hm);
}
if (tr.getAllElements(HTMLElementName.A).size() < 3)
continue;
Element po = (Element) td.getAllElements(HTMLElementName.A).get(2);
hm.put("position",(po.getContent().toString()));
//data.add(hm);
}
data.add(hm);
}
}catch(UnsupportedEncodingException e){
e.printStackTrace();
}
}
}
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
search_list1.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="@drawable/bg" >"
<TextView
android:id="@+id/search"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="13px" />
<TextView
android:id="@+id/search2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20px" />
<ListView
android:layout_height="wrap_content"
android:id="@+id/listView1"
android:layout_marginTop="80dp"
android:layout_marginBottom="50dp"
android:layout_width="match_parent"
android:cacheColorHint="#00000000">
</ListView>
</LinearLayout>
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
search_list2.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#00000000"
android:gravity="center_vertical|center_horizontal">
<RelativeLayout
android:id="@+id/relative"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="7dp"
android:layout_width="fill_parent">
<TextView
android:id="@+id/title"
android:layout_margin="7dp"
android:layout_gravity="center_horizontal"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:text="도서명"
android:layout_height="wrap_content"
android:textColor="#FF000000"
android:layout_width="fill_parent" android:textSize="13sp"/>
<TextView
android:id="@+id/writer"
android:layout_margin="7dp"
android:layout_gravity="center_horizontal"
android:layout_alignParentLeft="true"
android:text="저자"
android:layout_height="wrap_content"
android:layout_below="@+id/title"
android:textColor="#FF000000" android:layout_width="fill_parent" android:textSize="13sp"/>
<TextView
android:id="@+id/company"
android:layout_margin="7dp"
android:layout_gravity="center_horizontal"
android:layout_alignParentLeft="true"
android:text="출판사"
android:layout_height="wrap_content"
android:layout_below="@+id/writer"
android:textColor="#FF000000" android:layout_width="fill_parent" android:textSize="13sp"/>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tb"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center_horizontal"
android:orientation="vertical" >
<TableRow
android:id="@+id/tb1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingTop="110dp"
android:orientation="horizontal" >
<TextView
android:id="@+id/position"
android:layout_marginLeft="6dp"
android:layout_gravity="center_horizontal"
android:layout_alignParentLeft="true"
android:text="소장위치"
android:layout_height="wrap_content"
android:layout_below="@+id/company"
android:textColor="#FF000000" android:layout_width="fill_parent" android:textSize="13sp"/>
<ImageButton
android:id="@+id/bt1"
android:layout_width="50dp"
android:layout_height="20dp"
android:layout_gravity="center_horizontal"
android:background="#00000000"
android:src="@drawable/searchbt" />"
</TableRow>
</TableLayout>
</RelativeLayout>
</LinearLayout>



