1 <?xml version="1.0" encoding="UTF-8"?> 2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 3 android:layout_width="match_parent" 4 android:layout_height="wrap_content" 5 android:background="@color/transparent" 6 android:orientation="vertical" 7 android:id="@+id/relative01" 8 android:padding="10dp"> 9 10 <!-- Item 动态信息--> 11 <TextView 12 android:id="@+id/txt_account_number" 13 android:layout_width="wrap_content" 14 android:layout_height="wrap_content" 15 android:singleLine="true" 16 android:text="" 17 android:textColor="@color/code31" 18 android:textSize="14sp" 19 android:gravity="center" 20 android:drawablePadding="10dp" 21 android:drawableLeft="@drawable/account__pay"/> 22 23 <!-- Item 静态信息--> 24 <TextView 25 android:id="@+id/txt_account_add" 26 android:layout_width="wrap_content" 27 android:layout_height="wrap_content" 28 android:gravity="center" 29 android:layout_marginTop="10dp" 30 android:drawableLeft="@drawable/account_add_small" 31 android:drawablePadding="10dp" 32 android:text="添加提现账户" 33 android:textColor="@color/code09" 34 android:textSize="14sp" /> 35 36 </LinearLayout>
1 public class MyAccountAdapter extends BaseAdapter { 2 public List<AccountModel> listData = new ArrayList<AccountModel>(); 3 public BaseActivity act; 4 5 public MyAccountAdapter(BaseActivity act, List<AccountModel> listData) { 6 this.act = act; 7 this.listData = listData; 8 } 9 10 @Override 11 public int getCount() { return listData.size(); } 12 13 @Override 14 public Object getItem(int position) { return listData.get(position); } 15 16 @Override 17 public long getItemId(int position) { return position; } 18 19 @Override 20 public View getView(int position, View view, ViewGroup parent) { 21 22 ViewHolder viewHolder = null; 23 if (view == null) { 24 viewHolder = new ViewHolder(); 25 view = LayoutInflater.from(act).inflate( R.layout.item_fm_account_main_fragment_listview, null); 27 viewHolder.textView1 = (TextView) view.findViewById(R.id.txt_account_number); 28 viewHolder.imageView2 = (TextView) view.findViewById(R.id.txt_account_add); 29 view.setTag(viewHolder); 30 } else { 31 viewHolder = (ViewHolder) view.getTag(); 32 } 33 34 // TextView textView1 = (TextView) view.findViewById(R.id.txt_account_number); 35 // TextView imageView2 = (TextView) view.findViewById(R.id.txt_account_add); 36 37 if (position == listData.size() - 1) { 38 viewHolder.textView1.setVisibility(View.GONE); 39 viewHolder.imageView2.setVisibility(View.VISIBLE); 40 } else { 41 // imageView2 = (TextView) view.findViewById(R.id.txt_account_add); 42 viewHolder.imageView2.setVisibility(View.VISIBLE); 43 // view.findViewById(R.id.txt_account_number).setVisibility(View.VISIBLE); 44 viewHolder.textView1.setVisibility(View.VISIBLE); 45 viewHolder.imageView2.setVisibility(View.GONE); 46 47 viewHolder.textView1.setText(listData.get(position).account); 48 } 50 return view; 51 } 52 54 class ViewHolder { 55 TextView textView1; 56 TextView imageView2; 57 } 58 }
1 list_account.setOnItemClickListener(new AdapterView.OnItemClickListener() { 2 @Override 3 public void onItemClick(AdapterView<?> parent, View view, int position, long id) { 4 if (position == listData.size()-1) { 6 FmXXXFragment fmXXXFragment = new FmXXXFragment(); 7 mActivity.showFragment(fmXXXFragment); 8 } 9 } 10 });
时间: 2024-11-10 15:50:26