最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Android studio listview實(shí)現(xiàn)列表數(shù)據(jù)顯示 數(shù)據(jù)循環(huán)顯示效果

 更新時(shí)間:2020年04月20日 10:41:03   作者:曉雨哥哥寫代碼  
這篇文章主要介紹了Android studio listview實(shí)現(xiàn)列表數(shù)據(jù)顯示 數(shù)據(jù)循環(huán)顯示功能,本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下

Android studio listview實(shí)現(xiàn)列表數(shù)據(jù)顯示

在這里插入圖片描述

樣式不好看!想要好看的樣式可以私我,我加!
item.xml

<?xml version="1.0" encoding="utf-8"?>
<!--item -->
<LinearLayout
 xmlns:android="http://schemas.android.com/apk/res/android"
 android:orientation="horizontal"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent">
 <!--姓名 -->
 <TextView
  android:layout_width="130dp"
  android:layout_height="wrap_content"
  android:id="@+id/name"
 />
 <!-- 性別-->
 <TextView
  android:layout_width="150dp"
  android:layout_height="wrap_content"
  android:id="@+id/sex"
 />
</LinearLayout>

main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  >
 <!-- 標(biāo)題 -->
 <LinearLayout
 android:orientation="horizontal"
 android:layout_width="fill_parent"
 android:layout_height="wrap_content">
 
 <TextView
  android:layout_width="130dp"
  android:layout_height="wrap_content"
  android:text="姓名"
 />
 
  <TextView
  android:layout_width="150dp"
  android:layout_height="wrap_content"
  android:text="姓名"
 />
 
</LinearLayout>
 <!-- ListView控件 -->
<ListView 
  android:layout_width="fill_parent" 
  android:layout_height="fill_parent" 
  android:id="@+id/listView"
  />
</LinearLayout>

MainActivity .java

public class MainActivity extends Activity {
	List<String> list;
	List<String> list1;
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    ListView listView = (ListView) this.findViewById(R.id.listView);
    
    //獲取到集合數(shù)據(jù)
    //名字列表,之后可以動(dòng)態(tài)加入數(shù)據(jù)即可,這里只是數(shù)據(jù)例子
    list = new ArrayList<>();
    list.add("小明");
    list.add("李華");
    list.add("張三");

		list1 = new ArrayList<>();
    list1.add("男");
    list1.add("男");
    list1.add("女");
    
    List<HashMap<String, Object>> data = new ArrayList<HashMap<String,Object>>();
    for(int i = 0; i < list .size(); i++){
    	HashMap<String, Object> item = new HashMap<String, Object>();
    	item.put("name", list.get(i));
    	item.put("sex", list1.get(i));
    	data.add(item);        
    }
    //創(chuàng)建SimpleAdapter適配器將數(shù)據(jù)綁定到item顯示控件上
    SimpleAdapter adapter = new SimpleAdapter(MainActivity.this, data, R.layout.item, 
    		new String[]{"name", "sex"}, new int[]{R.id.name, R.id.sex});
    //實(shí)現(xiàn)列表的顯示
    listView.setAdapter(adapter);
  }
}

總結(jié)

到此這篇關(guān)于Android studio listview實(shí)現(xiàn)列表數(shù)據(jù)顯示 數(shù)據(jù)循環(huán)顯示效果的文章就介紹到這了,更多相關(guān)Android studio listview數(shù)據(jù)顯示 內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評(píng)論

北票市| 元朗区| 遂平县| 神农架林区| 古蔺县| 邯郸县| 靖远县| 根河市| 土默特左旗| 德昌县| 丰城市| 尤溪县| 康平县| 洛南县| 榆林市| 天峻县| 金阳县| 乐昌市| 兴和县| 易门县| 梁平县| 政和县| 富蕴县| 无为县| 新平| 宜城市| 梅河口市| 通州区| 普格县| 山东| 澎湖县| 治多县| 赣榆县| 阳原县| 凤凰县| 岱山县| 比如县| 治县。| 曲沃县| 大冶市| 贺州市|