ListView如何實現(xiàn)簡單列表,供大家參考,具體內(nèi)容如下
創(chuàng)新互聯(lián)自2013年創(chuàng)立以來,是專業(yè)互聯(lián)網(wǎng)技術(shù)服務(wù)公司,擁有項目網(wǎng)站建設(shè)、成都網(wǎng)站建設(shè)網(wǎng)站策劃,項目實施與項目整合能力。我們以讓每一個夢想脫穎而出為使命,1280元察哈爾右翼后做網(wǎng)站,已為上家服務(wù),為察哈爾右翼后各地企業(yè)和個人服務(wù),聯(lián)系電話:13518219792效果圖:
啥也沒干的ListView張這樣:
fry.Activity01
package fry; import com.example.ListView.R; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.Toast; public class Activity01 extends Activity implements OnItemClickListener{ private ListView listView; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.activity01); listView=(ListView) findViewById(R.id.listView); ArrayAdapteradapter=new ArrayAdapter (this, android.R.layout.simple_expandable_list_item_1, getData()); listView.setAdapter(adapter); listView.setOnItemClickListener(this); } @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // TODO Auto-generated method stub String string=(String) parent.getItemAtPosition(position); Toast.makeText(this, string, Toast.LENGTH_SHORT).show(); } private String[] getData(){ return new String[]{"韓寒","蔡靜","盧本偉","五五開","戰(zhàn)狼2","朝陽兄","虹橋一姐","犀利哥","王寶慶", "系大大","搞踹踹","張三","李四","王五"}; } }