AndroidListView实现简单列表功能-创新互联
ListView如何实现简单列表,供大家参考,具体内容如下
创新互联自2013年创立以来,是专业互联网技术服务公司,拥有项目网站建设、成都网站建设网站策划,项目实施与项目整合能力。我们以让每一个梦想脱颖而出为使命,1280元察哈尔右翼后做网站,已为上家服务,为察哈尔右翼后各地企业和个人服务,联系电话: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[]{"韩寒","蔡静","卢本伟","五五开","战狼2","朝阳兄","虹桥一姐","犀利哥","王宝庆", "系大大","搞踹踹","张三","李四","王五"}; } }
文章名称:AndroidListView实现简单列表功能-创新互联
本文地址:http://ybzwz.com/article/heoop.html