티스토리 뷰

<?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;   
 }
}

저작자 표시
신고
댓글
댓글쓰기 폼