展開可能なリストビューにアルファベット区切り記号を実装する必要があります。私は次のことを試しました。テキストビューを非表示にします。展開可能なリストのグループ ビュー内の項目が新しいアルファベットで始まる場合にのみ表示されます。次のコードは、予期しない場所で区切りを示しています。親切に助けてください。
mAdapter = new SimpleExpandableListAdapter(this, groupDataCat,
R.layout.word_list_item, new String[] { WORD },
new int[] { R.id.tvWord }, childDataCat,
R.layout.meaning_list_item, new String[] { MEANING },
new int[] { R.id.tvMeaning }){
@Override
public View getChildView(int groupPosition,
int childPosition, boolean isLastChild,
View convertView, ViewGroup parent) {
TextView tv = (TextView) super.getChildView(groupPosition, childPosition, isLastChild,convertView, parent);
tv.setTypeface(Typeface.createFromAsset(WordListActivity.this.getAssets(), "roboto_regular.ttf"));
return tv;
}
@Override
public View getGroupView(int groupPosition,
boolean isExpanded, View convertView,
ViewGroup parent) {
RelativeLayout rl = (RelativeLayout) super.getGroupView(groupPosition, isExpanded, convertView, parent);
TextView tv=(TextView) rl.findViewById(R.id.tvWord);
TextView sep=(TextView) rl.findViewById(R.id.separator);
Log.d("amitgroup",""+tv.getText().toString().charAt(0));
if (tv.getText().toString().charAt(0) != lastChar){
sep.setVisibility(View.VISIBLE);
}
lastChar = tv.getText().toString().charAt(0);
tv.setTypeface(Typeface.createFromAsset(WordListActivity.this.getAssets(), "roboto_regular.ttf"));
return rl;
}
};