• 对于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));
         }
         
         
         
         
         
        }

  • 相关阅读:
    网络通信socket连接数上限
    图像轮廓的提取
    C# 基础类型的快速转换
    十大编程算法助程序员走上高手之路
    椭圆的曲线模拟
    覆盖父类方法的new和override关键字
    BackgroundWorker异步更新界面
    小程序开发(七)利用SQL实现access_token的自动通知
    漫水填充(泛洪填充、油漆桶)的C#实现(解决堆溢出问题)
    SQL中获取最近的N个半年度
  • 原文地址:https://www.cnblogs.com/wangheblog/p/3100132.html
Copyright © 2020-2023  润新知