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

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)顯示功能,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),對大家的學(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ù)
    //名字列表,之后可以動態(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)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • Android ListView列表優(yōu)化的方法詳解

    Android ListView列表優(yōu)化的方法詳解

    列表 ListView 是應(yīng)用中最為常見的組件,而列表往往也會承載很多元素,這時(shí)就需要對其進(jìn)行優(yōu)化。本文介紹了 Flutter ListView 的4個(gè)優(yōu)化要點(diǎn),非常實(shí)用,需要的可以參考一下
    2022-05-05
  • Android仿新浪微博oauth2.0授權(quán)界面實(shí)現(xiàn)代碼(2)

    Android仿新浪微博oauth2.0授權(quán)界面實(shí)現(xiàn)代碼(2)

    這篇文章主要為大家詳細(xì)介紹了Android仿新浪微博oauth2.0授權(quán)界面實(shí)現(xiàn)代碼,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2016-11-11
  • Android仿人人網(wǎng)滑動側(cè)邊欄效果

    Android仿人人網(wǎng)滑動側(cè)邊欄效果

    這篇文章主要為大家詳細(xì)介紹了Android仿人人網(wǎng)滑動側(cè)邊欄效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2016-09-09
  • android webview獲取html代碼和根據(jù)id獲取value實(shí)例

    android webview獲取html代碼和根據(jù)id獲取value實(shí)例

    這篇文章主要介紹了android webview獲取html代碼和根據(jù)id獲取value實(shí)例,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2020-03-03
  • Android開發(fā)中MotionEvent坐標(biāo)獲取方法分析

    Android開發(fā)中MotionEvent坐標(biāo)獲取方法分析

    這篇文章主要介紹了Android開發(fā)中MotionEvent坐標(biāo)獲取方法,結(jié)合實(shí)例形式分析了MotionEvent獲取坐標(biāo)的相關(guān)函數(shù)使用方法與相關(guān)注意事項(xiàng),需要的朋友可以參考下
    2016-02-02
  • Android實(shí)現(xiàn)搖一搖簡單功能

    Android實(shí)現(xiàn)搖一搖簡單功能

    這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)搖一搖簡單功能,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2021-03-03
  • Android 調(diào)用系統(tǒng)相機(jī)拍攝獲取照片的兩種方法實(shí)現(xiàn)實(shí)例

    Android 調(diào)用系統(tǒng)相機(jī)拍攝獲取照片的兩種方法實(shí)現(xiàn)實(shí)例

    這篇文章主要介紹了Android 調(diào)用系統(tǒng)相機(jī)拍攝獲取照片的兩種方法實(shí)現(xiàn)實(shí)例的相關(guān)資料,一種是通過Bundle來獲取壓縮過的照片,一種是通過SD卡獲取的原圖,需要的朋友可以參考下
    2016-11-11
  • Android實(shí)現(xiàn)實(shí)時(shí)滑動ViewPager的2種方式

    Android實(shí)現(xiàn)實(shí)時(shí)滑動ViewPager的2種方式

    這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)實(shí)時(shí)滑動ViewPager的2種方式,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2016-10-10
  • Android?IdleHandler使用方法詳解

    Android?IdleHandler使用方法詳解

    這篇文章主要為大家介紹了Android?IdleHandler使用示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-11-11
  • Flutter路由框架Fluro使用教程詳細(xì)講解

    Flutter路由框架Fluro使用教程詳細(xì)講解

    在Flutter應(yīng)用開發(fā)過程中,除了使用Flutter官方提供的路由外,還可以使用一些第三方路由框架來實(shí)現(xiàn)頁面管理和導(dǎo)航,F(xiàn)luro作為一款優(yōu)秀的Flutter企業(yè)級路由框架,F(xiàn)luro的使用比官方提供的路由框架要復(fù)雜一些,但是卻非常適合中大型項(xiàng)目
    2022-10-10

最新評論