• 74、在ListView最后一项添加一个静态Item数据


     1 <?xml version="1.0" encoding="UTF-8"?>
     2 <LinearLayout
     3     xmlns:android="http://schemas.android.com/apk/res/android"
     4     android:layout_width="match_parent"
     5     android:layout_height="wrap_content"
     6     android:background="@color/transparent"
     7     android:orientation="vertical"
     8     android:id="@+id/relative01">
    11     <TextView
    12         android:id="@+id/txt_account_number"
    13         android:layout_width="wrap_content"
    14         android:layout_height="wrap_content"
    15         android:padding="10dp"
    16         android:singleLine="true"
    17         android:text=""
    18         android:textColor="@color/code31"
    19         android:textSize="14sp"
    20         android:gravity="center"
    21         android:drawablePadding="10dp"
    22         android:drawableLeft="@drawable/account__pay"/>
    23 
    24     <LinearLayout
    25         android:id="@+id/layout_add"
    26         android:layout_width="match_parent"
    27         android:layout_height="wrap_content"
    28         android:orientation="vertical">
    29         <View
    30             android:layout_width="match_parent"
    31             android:layout_height="10dp"
    32             android:background="@color/bg_home"/>
    33         <TextView
    34             android:id="@+id/txt_account_add"
    35             android:layout_width="wrap_content"
    36             android:layout_height="wrap_content"
    37             android:gravity="center"
    38             android:padding="10dp"
    39             android:drawableLeft="@drawable/account_add_small"
    40             android:drawablePadding="10dp"
    41             android:text="添加提现账户"
    42             android:textColor="@color/code09"
    43             android:textSize="14sp" />
    44     </LinearLayout>
    45 
    46 </LinearLayout>
     1 public class MyAccountAdapter extends BaseAdapter {
     2 
     3     public List<AccountModel> listData = new ArrayList<AccountModel>();
     4     public BaseActivity act;
     5 
     6     public MyAccountAdapter(BaseActivity act, List<AccountModel> listData) {
     7         this.act = act;
     8         this.listData = listData;
     9     }
    10 
    11 
    12     @Override
    13     public int getCount() {
    14         return listData.size();
    15     }
    16 
    17     @Override
    18     public Object getItem(int position) {
    19         return listData.get(position);
    20     }
    21 
    22     @Override
    23     public long getItemId(int position) {
    24         return position;
    25     }
    26 
    27     @Override
    28     public View getView(int position, View view, ViewGroup parent) {
    29 
    30         ViewHolder viewHolder = null;
    31         if (view == null) {
    32             viewHolder = new ViewHolder();
    33             view = LayoutInflater.from(act).inflate(R.layout.item_fm_account_main_fragment_listview, null);
    34             viewHolder.textView1 = (TextView) view.findViewById(R.id.txt_account_number);
    35           //  viewHolder.imageView2 = (TextView) view.findViewById(R.id.txt_account_add);
    36             viewHolder.layout_add = (LinearLayout) view.findViewById(R.id.layout_add);
    37 
    38             view.setTag(viewHolder);
    39         } else {
    40             viewHolder = (ViewHolder) view.getTag();
    41         }
    42 
    43         // TextView textView1 = (TextView) view.findViewById(R.id.txt_account_number);
    44         // TextView imageView2 = (TextView) view.findViewById(R.id.txt_account_add);
    45 
    46         viewHolder.textView1.setText(listData.get(position).account);
    47 
    48         if (position == (listData.size()-1)) {
    49          //   viewHolder.textView1.setVisibility(View.GONE);
    50 
    51             viewHolder.layout_add.setVisibility(View.VISIBLE);
    52             viewHolder.layout_add.setOnClickListener(new View.OnClickListener() {
    53                 @Override
    54                 public void onClick(View v) {
    55                     UserInfo.ACCOUNT_STATE = true;
    56                     FmAccountAddOneFragment fmAccountAddOneFragment = new FmAccountAddOneFragment();
    57                     act.showFragment(fmAccountAddOneFragment);
    58                 }
    59             });
    60         } else {
    61             viewHolder.layout_add.setVisibility(View.VISIBLE);
    62             viewHolder.textView1.setVisibility(View.VISIBLE);
    63             viewHolder.layout_add.setVisibility(View.GONE);
    64         }
    65 
    66         return view;
    67     }
    68 
    69 
    70     class ViewHolder {
    71         TextView textView1;
    72       //  TextView imageView2;
    73         LinearLayout layout_add;
    74     }
    75 }
  • 相关阅读:
    记录一下最近面试的总结
    网络模块相关面试题
    JVM 之类加载器
    一段简单的关于字符串的 Java 代码竟考察了这么多东西
    LeetCode 链表题 ( Java )
    MD5 加盐加密
    SpringMVC 学习笔记
    [redis]dict和rehash
    [redis]SDS和链表
    [go]包和工程管理
  • 原文地址:https://www.cnblogs.com/androidsj/p/5292285.html
Copyright © 2020-2023  润新知