午夜剧场伦理_日本一道高清_国产又黄又硬_91黄色网战_女同久久另类69精品国产_妹妹的朋友在线

您的位置:首頁技術文章
文章詳情頁

Android studio listview實現列表數據顯示 數據循環顯示效果

瀏覽:164日期:2022-09-24 17:07:35

Android studio listview實現列表數據顯示

Android studio listview實現列表數據顯示 數據循環顯示效果

樣式不好看!想要好看的樣式可以私我,我加!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: /> <!-- 性別--> <TextView android:layout_width='150dp' android:layout_height='wrap_content' android: /></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' > <!-- 標題 --> <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: /></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);//獲取到集合數據 //名字列表,之后可以動態加入數據即可,這里只是數據例子 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); } //創建SimpleAdapter適配器將數據綁定到item顯示控件上 SimpleAdapter adapter = new SimpleAdapter(MainActivity.this, data, R.layout.item, new String[]{'name', 'sex'}, new int[]{R.id.name, R.id.sex}); //實現列表的顯示 listView.setAdapter(adapter); }}

總結

到此這篇關于Android studio listview實現列表數據顯示 數據循環顯示效果的文章就介紹到這了,更多相關Android studio listview數據顯示 內容請搜索好吧啦網以前的文章或繼續瀏覽下面的相關文章希望大家以后多多支持好吧啦網!

標簽: Android
相關文章:
主站蜘蛛池模板: 亚洲天堂av中文字幕 | 亚洲成人7777 | 亚洲少妇一区二区三区 | 天天干天天谢 | 国产精品久久久久久久久 | 日韩一二三四 | 欧美精品亚洲精品 | 在线观看aa| 精品国产一区在线 | 欧美国产日韩在线观看 | 美国黄色a级片 | 成人看的视频 | 精品一区二区三区在线观看视频 | 亚洲一区二区在线播放 | 亚洲婷婷丁香 | 在线视频中文 | 久久国产精品免费视频 | jizz国产在线 | 91免费福利视频 | 亚洲一区网 | 天堂婷婷 | 手机看片亚洲 | 五月天狠狠操 | 艳妇乳肉亭妇荡乳av | 天堂中文资源在线观看 | www.一区二区三区 | 亚洲污视频| 亚洲欧洲日韩av | 毛片大全在线观看 | 国产成人一级 | 久久手机免费视频 | 另类图片av | 蜜乳av一区二区 | 男人午夜视频 | www免费网站在线观看 | 午夜成年 | 久久乐精品 | 亚洲免费一级片 | 日韩xxx视频| 丁香六月婷婷 | 国产高清露脸 |