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 | 31 |
Tags
- AWT
- paint
- 기본
- Graphic
- struts2
- 생성자
- 배열
- Java
- layout
- 이클립스
- 예외처리
- oracle
- Android
- 국제화
- 안드로이드
- Menu
- 어노테이션
- 메서드
- Spring
- 클래스
- 에러페이지
- 메소드
- JavaScript
- mybatis
- JSP
- 오버로딩
- Eclips
- OGNL
- 전화걸기
- HTML
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; ArrayListitems=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 |