Info

(i l.mi^ T t ListView ill t ArrayAdapter 8SfilA<JJ*J£. -&MSK«--.

tl Jfe ListView ffliiWif -JiiU-fj t Text Vie Wt liij J-|. Text View fflj&KlrtiMI IJiiHffl

^N'i&ifi toString()/; vj/l-Jj\c^J'r-i'i ^o ActivityList2 I-1 SimpleAdapter #11 ListView

TSiiJ^Wyi^WTfliAWffl/'MlJfeSiJtto nmxi ListView P.iiM«—JjSiair^ttifc'ftjM. mum ~ Simple Adapter*

i+^JL SimpleAdapter?

! SimpleAdapter-feft ListAdapter^ifti iji± SimpleAdapter 4 W it ListView

ArrayAdapter WftfflfiKfflin ListView fljftjffiift, "rfS SimpleAdapter WflFffl® ArrayList #11 ListView Wtif, ffiTSttjSfKjfi, ArrayList AS»® ^ Map<String,

AirayList^M'W^-flS Map XtftfSin ListView + W -«»tr»«»®» -

fi -T SimpleAdapter WWiSa». SimpleAdapter MJtaT*^ ^MMWitfl F0T'J<:

I public SimpleAdapter(Context context, List<? extends Map<String, ?» data, int resource, St ring[] from, int[] to)

. Context , Ki'WSffl^jiaio

• Data, ifi ]■ Map (ft Listo Data MiifcJ** ^'ffifU ListView flSXi/So Data Sj&M U-W& t Map m®. «>h Map mM&ft T ListView U -frffiBffiSMK.

data new ArrayList<Map<String, Object»();

• Resoure, ¡¿^ Resoure layout, layout MfcWKtil^ffi to ^ ttiStWW® View«, JR if] £ « is « M A Ml 61 7 , ^ & til »1 W n Li £ * • « Sc {ft M Yj Android.R.layout.

simple list item single choice. Android.R.layout.two line list item

• From, ail-^^Wftffl. ^«^fiJ^TiE ArrayList «fW**—Is* item Map<String, Object>fi<J Object fflMo

• To, ^TextView Text1View id (HI Android.R.id.textl , i^textl ft layout Initio ff View ft TextView«

& F*fJ" ff ActivityList2 jtfl=, KMA frSSSMW:

private void PrepareData() {

data = new ArrayList<Map<String, Object>>();

Map<String, 0bject> item;

item = new HashMap<String, ObjectX);

item.put ;

item = new HashMap<String, 0bj..ect>(); item, put "IS^");

item, put Cflfll", "IS") ; data.add(item);

item = new HashMap<String, 0bject>(); item.puL "/J^Wflf") ;

JStl PrepareData() ft «JSmfiffifr»® fl-fc ListView fiiASa^WSIB. -RffJWifi / t ArrayList<Map<String, Object»()» '^ + Map fli^o

KonCreateOmiiW^flfti^W:

super.onCreate(savedlns.anceState); PrepareData();

listView new ListView (this);

SimpleAdapter adapter new SimpleAdapter(this, data, R. layout. listitem, new String [] { "tMJ" \, new int I ] I

R.id.mviewl, R.id.mview2 }); 1istView.setAdapter(adapter); setCoritentView (list View) ;

• Prepare Data( )iliiijM~ t Map ArrayList

• list View = new ListView(this)iS^J ListView •

• SimpleAdapter adapter = new SimpleAdapter(this, data,R.layout.list item, new String[| { "'/I <V\ "tt#J" }, new int[] {R.id.mviewl, R.id.mview2 )), SfUft jff'-krti"* SimpleAdapter ftl

• R.layout.list item listitem.xml i'fl Layout, ii* Layout ListView

• String!] { "ttaj" >. an—* String Saiii-^t-Wf^JD+ttfKl^flMap M^'I'lMio tfiJitfl, r ^'l', PrepareDataO^&a^ttir item.put("tt£H, "Sfc^"),

ListView item.get(,,«:4$,,)& *'JK ir^^ifiiR # [iff. ListView "

• int[] {R.id.mviewl, R.id.mview2 listjtem.xml Mii&XMW*Text'View (l<J Ido KiMffii»&iS- F> ListView ^ffl^^-fj'Wt Text View, data[i].get(M»*i")

iWiftM^A id % mviewl fft TextView data[i].get("fl- >}'J")flWlM/J<# id mview2 fft TextView h, inm 7-52 rr>j<c

4 ftSimpleAdapter adapter = new SimplcAdapter(this, data,R.layout.list item, : new String!] < }, new int[] {R.id.mviewl, R.id.mview2 })+, Bit T "IK

/'hSES ; ft^fi R.layout.list item *b> tt t ft Android

: Android.R.layout.simple list item_2. +

mser^Jf^-Android S^i&^frlS

Android Layout
* RI 7-52 RfflîAhtiâ^^a »S1/-53 fëffl Andre id.ltlayout.simpleJist_itein_2
0 0

Post a comment