ISAifAl I W Liston Crcatc vA sfcJftf Wftl KfJ

^Override public void onCreate(Bundle savedlnstanceState) ( s upe r. onCr ea t e (saved Ins: anceS ta t e) ; setContentView(R.iayout.ma in);

itemlist (ListView) findViewByld(R.id.itemlist); refreshListItems(); \

l-.j^^fi'HtKii'ilW, refreshListltcmsOK&MWt refrcshl istltems( ♦ 'i-iKWH^N K#M<:

private void refreshListltems() ( list - buiIdList ForSimp IeAdapte r();

SimpleAdapter notes - new Siir.pleAdapt.er(this, list, R.layout.item_row, new St ring | | ( "name", "desc:", " img" ), new int [ ] { R. id. name, R.id.desc, R.id.img I); iLemli st.setAdapter(notes); itemlist.setonT temCiic k i .1 s t ener(this) ;

itemlist.setSelection(0); »

fWllfuM^&'JIJtJ bui 1 dListForSimpieAdapter JjWfkfcft¥ffvi<:

private List<Map<String, Object>> buildListForSimpleAdapter() ( List<Map<String, Object» list = new ArrayList<Map<String, Obiect.>> (3) ; // W: sL—^ HashMap

Map<String, 0bject> map new HashMap<String, Object>(); map.put ("name", "^SfcfiB");

map.put("img", R.drawable.system); list.add(map);

map = new HashMap<String, Object>(); map.put ("name", "5£#fi&") ;

map.pur ("desc", CPU. l^jfj^f^fsS. ") ;

map.pu t("img", R.drawab e.ha rdwa re); list.add(map);

map = new HashMap<String, Object>(); map . put ( "name", "") ; map.put ("desc", "«eSSfcW&ttteJSL. ") ; map. pu t ( " i mg ", F.. dr awab 1e.sof twa re) ; 1ist.add(map);

map - new HashMap<St. ring, Object>(); map. pu t (" name ", "istr^tiB &") ; map. put ("desc", "i^iS&slbBi & . ") ; map.put("img", R.drawable.running); list.add(map);

map - new HashMap<String, Object>(); map.put ("name", " £14 M'fiM") ; map. put ("desc" , "M ft&mXft . ") ; map.put ("img", R.drawable.file explorer); list.add(map); return list; )

li^ buildListForSimpleAdapter()^-y£^5i List (^ij-fe), A^M ftl^lflSi&iS

WXi re fresh L i stl tem s() Jf ii, ' j IA SimpleAdapter ffliSfidjj'fl., Kit Hi t^'MM item row.xml yWMRJtfh item row.xml

<?xm1 version^"1.0" encoding="utf-8"?> < LinearLayout xmlns:android^"http://schcmas.android.com/apk/res/android" android:id="@+id/vwl" android:layout width="fill parent" android:1ayout_height - "wrap_content" android:paddinq "4px" android:orientation "horizontal">

<ImageView android:id="@+id/img" android:la you t_w i dth="32px" android:layout margin="4px" android:layout height^"32px"/>

<LinearLayout android:layOuL_width="wrap content" android:layout height="wrap_content" android:orientation = "vert ical">

<TextView android:id="@+id/name" android:textSize="18sp" android:textstyle="bold" android:layout_width="fi11 parent" android:layout_height-"wrap content"/>

<TextView android:id="(a + id/desc" android:textSize="14sp" android:layout width="fill_parent" android:paddinqLeft="20px" android:layout height="wrap_content"/>

</LinearLayout>

</LinearLayout>

HI^j&H, ^■Ym^ir^m -friftrt'-ft. ftiiir&JftiaiK \ 6-2 ffr*.

eoofnftKAitbtimt

^XtonltemClick. 'SW^Wtal

(¡¡Override public void onltemClick(AdapterView<?> parent, View v, int position, long id) ( Intent intent - new Intent();

Log.i{TAG, "item clicked! + position - ")"); switch (position) ( case 0:

intent.setClass(eoelnfosAssistant.this, System.class); startActivity(intent); break; case 1:

intent.setClass(eoelnfosAssistant.this. Hardware.class); sta r t. Ac t i vi t y (1n tent) ; break; case 2:

intent.setClass(eoelnfosAssi stant.this, Software.class); startAct i vit.y (intent) ; break; case 3:

intent.setClass(eoelnfosAssistant.this, Runing.class);

break;

imrnn.:

0 0

Post a comment