編輯:Android開發教程
SimpleAdapter作為一個數據集,主要向ListView、GridView容器填充數據,總結了幾種填充方式,原理很簡單,直接看代碼 和效果圖
1、 ListView單行顯示(simple_list_item_1)
代碼:
public class myListItem1 extends
Activity{
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
ListView listView = new ListView(this);
List<Map<String, String>> mList = new ArrayList<Map<String, String>>();
for(int i=0; i<10; i++){
Map<String, String> map = new HashMap<String, String>();
map.put("TITLE", "Test Title");
map.put("CONTENT", "Test Content");
mList.add(map);
}
SimpleAdapter adapter = new SimpleAdapter(this,
mList,
android.R.layout.simple_list_item_1, // List 顯示一行item1
new String[]{ "CONTENT" }, // "TITLE",
new int[]{ android.R.id.text1 }
);
listView.setAdapter(adapter);
setContentView(listView);
}
}
效果:

android技巧:如何在android應用中插入百度廣告
1.介紹現在游戲中的廣告基本上已經成為了游戲創作者的一個重要的收入來源。其實插入廣告還是挺簡單的,本文選擇百度廣告聯盟作為案例(總覺得百度不會拖欠工資)。注:不過,插入廣
基於Android 4.4系統的nubia UI 2.0
5月15日nubia UI 2.0開啟公測(基於Android 4.4),首批機型:Z5、Z5 mini、Z5S mini。全新的nubia UI 2.0,扁平、簡約的U
android的開發調試工具
android開發中,解決bug有很多優秀的工具,現列舉如下:一.charles:網絡抓包神器專解各種網絡解析錯誤等網絡異常重定向host的方法:1. charles的m
Android的任務和回退棧簡介
一個應用通常有多個Activity。每個activity圍繞一個特定的功能設計,用戶可以操作它並且可以啟動其他的activity。舉個例子,一個電子郵件應用可能有一個ac