Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | ||||||
| 2 | 3 | 4 | 5 | 6 | 7 | 8 |
| 9 | 10 | 11 | 12 | 13 | 14 | 15 |
| 16 | 17 | 18 | 19 | 20 | 21 | 22 |
| 23 | 24 | 25 | 26 | 27 | 28 | 29 |
| 30 |
Tags
- 안드로이드
- HTML
- Menu
- oracle
- 클래스
- JSP
- Spring
- mybatis
- 메소드
- Android
- JavaScript
- layout
- 오버로딩
- 메서드
- 에러페이지
- Graphic
- 기본
- 이클립스
- 배열
- 국제화
- Eclips
- paint
- struts2
- AWT
- OGNL
- 생성자
- 어노테이션
- Java
- 전화걸기
- 예외처리
Archives
- Today
- Total
note
XML Resource 본문
<?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" > <TextView android:id="@+id/selection" android:layout_width="fill_parent" android:layout_height="wrap_content" /> <ListView android:id="@android:id/list" android:layout_width="fill_parent" android:layout_height="fill_parent" android:drawSelectorOnTop="false" /> </LinearLayout>
package com.commonsware.android.resources;
import java.util.ArrayList;
import org.xmlpull.v1.XmlPullParser;
import android.app.ListActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
public class XMLResourceDemo extends ListActivity {
TextView selection;
ArrayList items=new ArrayList();
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
selection=(TextView)findViewById(R.id.selection);
try{
XmlPullParser xpp =getResources().getXml(R.xml.words);
while(xpp.getEventType()!=XmlPullParser.END_DOCUMENT){
if(xpp.getEventType()==XmlPullParser.START_TAG){
if(xpp.getName().equals("word")){
items.add(xpp.getAttributeValue(0));
}
}
xpp.next();
}
}
catch(Throwable t){
Toast.makeText(this, "실패 : "+t.toString(),4000).show();
}
setListAdapter(new ArrayAdapter(this,android.R.layout.simple_list_item_1,items));
}
public void onListItemClick(ListView parent, View v , int position, long id){
selection.setText(items.get(position).toString());
}
}
'Android > 기본' 카테고리의 다른 글
| Access Web Image (0) | 2012.01.13 |
|---|---|
| Read JSON (0) | 2012.01.13 |
| StaticFile (0) | 2012.01.12 |
| Read Write File (자동 저장할때 사용) (0) | 2012.01.12 |
| Access Web (0) | 2012.01.12 |