일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- 업캐스팅
- 다형성
- Validations
- 추상클래스
- 다운캐스팅
- 단축키
- 야구게임
- 전자정부
- 자바
- 25가지 효율적인 sql작성법
- Random
- 상속
- 로또
- 자바 야구게임
- 가변인자
- angular2
- while
- 전체
- 전체텍스트
- 페이징
- full text indexing
- 이클립스
- Full text
- 형변환
- 스프링
- Login with OAuth Authentication
- IBatis procedure
- jquery
- 상속예제
Archives
- Today
- Total
nalaolla
List_View 본문
728x90
반응형
MainActivity.java
- package com.test.android07listview;
- import android.support.v7.app.AppCompatActivity;
- import android.os.Bundle;
- import android.util.Log;
- import android.view.View;
- import android.widget.AdapterView;
- import android.widget.ArrayAdapter;
- import android.widget.ListView;
- import java.util.ArrayList;
- public class MainActivity extends AppCompatActivity {
- String[] members = new String[]{
- "KIM1", "KIM2","KIM3","KIM4","KIM5",
- "KIM1", "KIM2","KIM3","KIM4","KIM5",
- "KIM1", "KIM2","KIM3","KIM4","KIM5",
- "KIM1", "KIM2","KIM3","KIM4","KIM5",
- "KIM1", "KIM2","KIM3","KIM4","KIM5"
- };
- ArrayList<String> list = new ArrayList<String>();
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- for (int i = 0; i < 40; i++) {
- list.add("palaoh"+i);
- }
- final String[] temps = getResources().getStringArray(R.array.list2);
- ListView lv = (ListView)findViewById(R.id.listView);
- lv.setAdapter(new ArrayAdapter<String>(this, R.layout.list_item, temps));
- lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
- @Override
- public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
- // Log.i("TestLog : ", list.get(position));
- Log.i("TestLog : ", temps[position]);
- }
- });
- } //end onCreate
- } //end class
activity_main.xml
- <?xml version="1.0" encoding="utf-8"?>
- <LinearLayout 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"
- android:paddingBottom="@dimen/activity_vertical_margin"
- android:paddingLeft="@dimen/activity_horizontal_margin"
- android:paddingRight="@dimen/activity_horizontal_margin"
- android:paddingTop="@dimen/activity_vertical_margin"
- android:orientation="vertical"
- tools:context="com.test.android07listview.MainActivity">
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="member list" />
- <ListView
- android:layout_width="match_parent"
- android:layout_height="389dp"
- android:id="@+id/listView" />
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="New Button"
- android:id="@+id/button" />
- </LinearLayout>
728x90
반응형
'ANDROID' 카테고리의 다른 글
table_layout (0) | 2016.02.10 |
---|