• Android之ListView优化


    public class MyAdapter extends BaseAdapter {
      private Context context;
      public List<Students> list;
      private LayoutInflater mLayoutInflater;

      public MyAdapter (Context context, List<Students> list) {
        this.context = context;
        this.list= list;
        mLayoutInflater = LayoutInflater.from(context);

      }

      @Override
      public int getCount() {
        return list.size();
      }
      @Override
      public Object getItem(int position) {
        return list.get(position);
      }
      @Override
      public long getItemId(int position) {

        return position;
      }
      @Override
      public View getView(final int position, View convertView, ViewGroup parent) {
        ViewHolder holder=null;
        if (convertView == null) {
          holder = new ViewHolder();

          convertView= mLayoutInflater.inflate(R.layout.students_item,null);
          holder.name=(TextView)convertView.findViewById(R.id.tv_name);
          holder.money = (TextView)convertView.findViewById(R.id.tv_money);
          holder.time= (TextView)convertView.findViewById(R.id.tv_time);

          //设置控件集到convertView
          convertView.setTag(holder);
        }
        else
        {
          holder = (ViewHolder)convertView.getTag();
        }
        Students students = list.get(position);
        //更新布局内容
        String name = students .getName();
        String amount = students .getMoney();

        String time = students .getDate();
        SimpleDateFormat sdf = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss" );
        SimpleDateFormat sdf2 = new SimpleDateFormat( "MM-dd" );

        try {
          Date date = sdf.parse( time );
          String time2 = sdf2.format(date);
          holder.time.setText(time2);
          holder.name.setText(name);
          holder.money.setText(amount);
        } catch (ParseException e) {
          e.printStackTrace();
      }


      return convertView;
    }
      private static class ViewHolder {

        TextView name;
        TextView money;
        TextView time;


      }

  • 相关阅读:
    kibana.yml(中文配置详解)
    Elasticsearch之marvel(集群管理、监控)插件安装之后的浏览详解
    ElasticSearch vs Lucene多维度分析对比
    ElasticSearch 应用场景
    ElasticSearch 在Hadoop生态圈的位置
    ElasticSearch 工作原理
    ElasticSearch 架构图
    ElasticSearch vs 关系型数据库
    Codeforces Round #311 (Div. 2)
    uva 568(数学)
  • 原文地址:https://www.cnblogs.com/awandxx/p/5283809.html
Copyright © 2020-2023  润新知