main.xml
<?xml version="1.0" encoding="utf-8"?>
list.xml
java
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ListView android:id="@+id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#000000"/>
</LinearLayout>
list.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">
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView android:id="@+id/writeDate"
android:layout_width="wrap_content"
android:layout_height="fill_parent"/>
<TextView android:id="@+id/title"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
</LinearLayout>
</ScrollView>
</LinearLayout>
java
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ListView listView = (ListView)findViewById(R.id.list);
SimpleAdapter adapter = new SimpleAdapter(this, makeList(arrayList), R.layout.list
, new String[]{ "writeDate", "title" }
, new int[]{ R.id.writeDate, R.id.title });
listView.setAdapter(adapter);
// SimpleAdapter 객체 생성 후 추가된 데이터가 있을 경우 아래 코드 실행
// adapter.notifyDataSetChanged();
}
private ArrayList<HashMap<String, String>> makeList(ArrayList<array> arrayList){
ArrayList<HashMap<String, String>> listMap = new ArrayList<HashMap<String,String>>();
for(int i = 0; i < rssArrayList.size(); i++){
map.put("writeDate", arrayList.get(i).getWriteDate());
map.put("title", arrayList.get(i).getTitle());
listMap[listNumber].add(map);
}
return listMap;
}
'Android' 카테고리의 다른 글
title 우측에 progress 출력 (0) | 2011.11.17 |
---|---|
앱에서 내장 브라우저 직접 호출 (0) | 2011.11.16 |
알림음 (0) | 2011.09.20 |
현재 사용중인 네트웍 종류 반환 (0) | 2011.09.20 |
화면 상태 (0) | 2011.09.06 |