我想向我的列表視圖中添加一個TextView,但是當我這樣做時,我會收到一個強制關閉。我試圖在歌曲前顯示歌名中的拳頭字母。歌曲列表是一個字符串arraylist,這是所有列表視圖。將textView作爲分隔符添加到ListView中
Collections.sort(songtitle);
TextView divide = (TextView)findViewById(R.layout.song);
adapter = new ArrayAdapter<String>(this,R.layout.song,songtitle);
int l= 0;
while(l < adapter.getCount()-1){
if(songtitle.get(l).charAt(0) == songtitle.get(l+1).charAt(0)){
adapter.add(songtitle.get(l));
}else{
String songname1 = songtitle.get(l);
String newString = songname1.substring(0,1);
divide.append(newString);// This is where i get the force close ... I want to display this textView ////
}
l++;
}
setListAdapter(adapter);
}
分享errorLog。還有songtitle arrayList。 –