티스토리 뷰

<?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:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="@string/hello"
    />
<Button android:text="Button" android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
</LinearLayout>













package com.antbee.AntListActivity;

import android.app.ListActivity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListAdapter;
//import android.widget.SimpleAdapter;

public class AntList extends ListActivity{
 ListAdapter adapter;
 @Override
 protected void onCreate(Bundle savedInstanceState) {
  // TODO Auto-generated method stub
  super.onCreate(savedInstanceState);
  adapter = createAdapter();       
     setListAdapter(adapter); //setView대신 setListAdapter를 사용
 }
 
  protected ListAdapter createAdapter()    {    //adapter = createAdapter(); 될때 내용을 만들도록 
   // Create some mock data     
   String[] testValues = new String[] {    //리스트 필드 내용을 넣는다.   
     "Test1",       
     "Test2",       
     "Test3"     
   };      
   // Create a simple array adapter (of type string) with the test values     
   ListAdapter adapter = new ArrayAdapter<String>(//어뎁터를 가지고 리스트를 뿌린다.
     this,
     android.R.layout.simple_list_item_1,
     testValues
  );      
   return adapter;   
 }
}

댓글

공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/03   »
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
글 보관함