zoukankan      html  css  js  c++  java
  • 对于ListView的ArrayAdapter重写

    listTag是标题;

    class MyAdapter extends ArrayAdapter<String>
        {

         public MyAdapter(Context context, int textViewResourceId,
           List<String> objects) {
          super(context, textViewResourceId, objects);
          // TODO Auto-generated constructor stub
         }

         @Override
         public View getView(int position, View convertView, ViewGroup parent) {
          // TODO Auto-generated method stub
          
          
           View view = convertView; 
                  //根据标签类型加载不通的布局模板  
                      if(listTag.contains(getItem(position))){ 
                         //如果是标签项 
                          view = LayoutInflater.from(getContext()).inflate(R.layout.group_list_item_tag, null); 
                      }else{ 
                         //否则就是数据项 
                          view = LayoutInflater.from(getContext()).inflate(R.layout.group_list_item, null); 
                     } 
                   //显示名称 
                   TextView textView = (TextView) view.findViewById(R.id.group_list_item_text); 
                      textView.setText(getItem(position)); 
                     //返回重写的view 
                     return view;
          
          
         }

         @Override
         public boolean areAllItemsEnabled() {
          // TODO Auto-generated method stub
          return super.areAllItemsEnabled();
         }

         @Override
         public boolean isEnabled(int position) {
          // TODO Auto-generated method stub
          return !listTag.contains(getItem(position));
         }
         
         
         
         
         
        }

  • 相关阅读:
    【Hive】HiveQL:数据定义
    【Hive】Hive安装与配置
    【Hadoop】Hadoop 2.7.6安装_伪分布式集群
    【RMAN】单实例环境RMAN备份和还原
    【SQL开发】Oracle 11g 分区技术
    【SQL开发】使用绑定变量 VS 不使用绑定变量
    MySQL索引最左前缀原则导致系统瘫痪
    阿里云RDS在线DDL工具gh-ost
    centos7下MongoDB3.4安装并解决告警
    ibtmp1文件过大
  • 原文地址:https://www.cnblogs.com/wangheblog/p/3100132.html
Copyright © 2011-2022 走看看