* 결과
'프로그래밍 > Android' 카테고리의 다른 글
TextView (0) | 2012.07.27 |
---|---|
View (0) | 2012.07.27 |
AdapterView(ListView, spinner) (0) | 2012.07.24 |
Tab을 이용한 화면 구성 - 실습 (0) | 2012.07.24 |
FrameLayout과 TableLayout (0) | 2012.07.24 |
package org.kosta.adpaterView.test;
import java.util.ArrayList;
import android.R.anim;
import android.os.Bundle;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.support.v4.app.NavUtils;
public class MainActivity extends Activity {
@SuppressLint("ParserError")
private ArrayAdapter<String> listAdapter;//List, 배열안의 리터럴 값을 View로 변환
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
/*
* AdapterView 생성
* 1. AdapterView 객체 조회(생성) - ListView
* 2. Data를 넣어서 Adapter객체 생성 - ArrayAdapter
* 3. AdapterView에 Adapter객체 설정
*/
ListView listView = (ListView) findViewById(R.id.list_view);
ArrayList list = new ArrayList();
list.add("대한민국");
list.add("중국");
list.add("태국");
list.add("일본");
listAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,list);//android.R.layout.simple_list_item_1 - 안드로이드 시스템에서 제공해주는 textView layout에 list 값을 넣어라.
listView.setAdapter(listAdapter);//AdapterView를 ListView에 하나씩 뿌려줌.
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="@+id/txt"
android:textSize="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="@dimen/padding_medium"
android:text="나라이름"
tools:context=".MainActivity" />
<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/txt"
android:id="@+id/list_view"/>
</RelativeLayout>
* 결과
TextView (0) | 2012.07.27 |
---|---|
View (0) | 2012.07.27 |
AdapterView(ListView, spinner) (0) | 2012.07.24 |
Tab을 이용한 화면 구성 - 실습 (0) | 2012.07.24 |
FrameLayout과 TableLayout (0) | 2012.07.24 |
by 조은성 |
||
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
내 블로그 - 관리자 홈 전환 |
Q
Q
|
---|---|
새 글 쓰기 |
W
W
|
글 수정 (권한 있는 경우) |
E
E
|
---|---|
댓글 영역으로 이동 |
C
C
|
이 페이지의 URL 복사 |
S
S
|
---|---|
맨 위로 이동 |
T
T
|
티스토리 홈 이동 |
H
H
|
단축키 안내 |
Shift + /
⇧ + /
|
* 단축키는 한글/영문 대소문자로 이용 가능하며, 티스토리 기본 도메인에서만 동작합니다.