欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Android ListView實(shí)現(xiàn)簡單列表功能

 更新時(shí)間:2017年08月23日 09:17:05   作者:飯飯_fan  
這篇文章主要為大家詳細(xì)介紹了Android ListView實(shí)現(xiàn)簡單列表功能,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

ListView如何實(shí)現(xiàn)簡單列表,供大家參考,具體內(nèi)容如下

效果圖:

啥也沒干的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);
  ArrayAdapter<String> adapter=new ArrayAdapter<String>(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","朝陽兄","虹橋一姐","犀利哥","王寶慶",
    "系大大","搞踹踹","張三","李四","王五"};
 }
}

/ListView/res/layout/activity01.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:orientation="vertical" >

 <ListView 
  android:id="@+id/listView"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  ></ListView>

</LinearLayout>

以上就是本文的全部內(nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論