列表活动两行列表项替代项
2022-09-04 01:50:57
我注意到 TwoLineListItem 从 API 17 开始被弃用。如果我按如下方式设置 ListActivity 适配器,则有什么替代方法?
ArrayAdapter<File> adapter = new ArrayAdapter<File>(this,android.R.layout.simple_list_item_2,filesArrayList){
@Override
public View getView(int position, View convertView, ViewGroup parent){
final TwoLineListItem row;
if(convertView == null){
LayoutInflater inflater = (LayoutInflater)getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
row = (TwoLineListItem)inflater.inflate(android.R.layout.simple_list_item_2, null);
}else{
row = (TwoLineListItem)convertView;
}
row.getText1().setText(filesArrayList.get(position).getTitle());
row.getText2().setText2(filesArrayList.get(position).getDescription());
return row;
}
};