【问题标题】:listview sort ascending in AndroidAndroid中的listview升序排序
【发布时间】:2017-09-07 21:30:28
【问题描述】:

我在这个项目中工作,但我不知道如何反向显示列表视图(升序)

艺人类

public class Artistlist extends ArrayAdapter<Artist> {

private Activity context;
private List<Artist> artistList;

public Artistlist(Activity context,List<Artist> artistList){
    super(context,R.layout.list_layout , artistList);

    this.context = context;
    this.artistList = artistList;


}

@NonNull
@Override
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
    LayoutInflater inflater = context.getLayoutInflater();

    View listViewItem = inflater.inflate(R.layout.list_layout,null,true);

    TextView textViewname = (TextView) listViewItem.findViewById(R.id.textView);
    TextView textViewGener = (TextView) listViewItem.findViewById(R.id.textView2);

    Artist artist = artistList.get(position);

    textViewname.setText(artist.getArtistName());
    textViewGener.setText(artist.getArtistGener());

    return listViewItem;
}

}

如何反向显示列表视图(升序) 谢谢你

【问题讨论】:

    标签: android database sorting listview firebase


    【解决方案1】:

    在将列表发送到适配器之前使用这行代码

    Collections.reverse(artistList);
    

    【讨论】:

      猜你喜欢
      • 2014-03-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-27
      相关资源
      最近更新 更多