我目前正在創建分段列表視圖。到目前爲止,我已經制作了一個帶有標題和項目列表的單一列表視圖。最終這應該變成我可以在我的項目中使用的模板。我需要知道的是如何將此頭在下面的代碼後添加頁眉和項目的相應列表:創建分段列表視圖
public class MainActivity extends Activity {
private ListView listView1;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Preferences preference1_data[] = new Preferences[]
{
new Preferences(R.drawable.bird, "Bird Preference"),
new Preferences(R.drawable.gear, "Gear Preference"),
new Preferences(R.drawable.planet, "Planet Preference"),
};
Preferences preference2_data[] = new Preferences[]
{
new Preferences(R.drawable.bird, "Bird Preference"),
new Preferences(R.drawable.gear, "Gear Preference"),
new Preferences(R.drawable.planet, "Planet Preference"),
};
PreferencesAdapter adapter = new PreferencesAdapter(this,
R.layout.listview_item_row, preference1_data);
listView1 = (ListView)findViewById(R.id.listView1);
// Add Preference 1 section
View header = (View)getLayoutInflater().inflate(R.layout.listview_header_row, null);
listView1.addHeaderView(header);
listView1.setAdapter(adapter);
// Add Preference 2 section
// What code goes here?
}
}
有沒有您選擇鏈接到網站上提供下載。 – CodePrimate 2012-03-20 12:09:18
使用SVN下載源代碼:http://code.google.com/p/android-amazing-listview/source/checkout 儘管只有兩個文件。所以你可以自己下載它們:http://code.google.com/p/android-amazing-listview/source/browse/#svn%2Ftrunk%2FAmazingListView%2Fsrc%2Fcom%2Ffoound%2Fwidget – 2012-03-20 17:03:07