嗨我有一個問題,試圖瞭解如何分段ListViews工作。我把它變成了一個普通的列表視圖。但現在我想將部分添加到我的列表中。如何在廣告中添加章節標題。Android Listview與章節
繼承人我的代碼有效。
public class ChooseTeamActivity extends ListActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.chooseact);
String FullData = getIntent().getStringExtra("FullData");
try{
JSONObject obj = new JSONObject(FullData);
List<String> leagues = new ArrayList<String>();
JSONObject objData = obj.getJSONObject("data");
JSONArray jArray = objData.getJSONArray("structure");
for (int i=0; i < jArray.length(); i++) {
JSONObject oneObject = jArray.getJSONObject(i);
leagues.add(oneObject.getString("league_website_name"));
JSONArray DivisionsArray = oneObject.getJSONArray("divisions");
for (int d=0; d < DivisionsArray.length(); d++){
JSONObject DivDict = DivisionsArray.getJSONObject(d);
leagues.add(DivDict.getString("name"));
}
}
setListAdapter (new ArrayAdapter<String>(this, R.layout.single_item,
leagues));
ListView list = getListView();
list.setTextFilterEnabled(true);
} catch (JSONException e) {
e.printStackTrace();
}
}
}
可能重複[在ListView中創建類別?](http://stackoverflow.com/questions/1013765/creating-categories-in-a-listview) – slayton 2012-04-25 15:51:44