1. 程式人生 > >Android listView item側滑實現刪除和置頂功能

Android listView item側滑實現刪除和置頂功能

         第一次寫部落格,先說下大概思路吧~

        要顯示item側滑顯示刪除,置頂。首先要隱藏一部分item的佈局(自定義隱藏佈局寬度,在adapter裡設定LayoutParams)。然後重寫listview的onInterceptTouchEvent()和onTouchEvent()方法,然後對listview的滑動進行判斷,最後進行相應的操作(刪除啦,置頂啦,取消置頂bulabula)。刪除需要dataList.remove(position),置頂就是將點選的item先執行dataList.add(0,object),然後執行dataList.remove(position),最後adapter.notifyDataSetChanged();先來兩張效果圖

1.新建attrs.xml,設定好自定義屬性(其實就是右邊隱藏佈局的寬度啦),程式碼很簡單,直接貼上來了

[html] view plain copy print?
  1. <?xmlversion=“1.0”encoding=“utf-8”?>
  2. <resources>
  3.     <declare-styleablename=“slidingitemlistview”>
  4.         <attrname=“right_width”format=“dimension”></attr>
  5.     </declare-styleable>
  6. </
    resources>
<?xml version="1.0" encoding="utf-8"?>
<resources>

    <declare-styleable name="slidingitemlistview">
        <attr name="right_width" format="dimension"></attr>
    </declare-styleable>
</resources>
2.繼承listview實現我們自己想要的效果~

(1)第一步在構造方法裡獲取自定義的寬度(右邊區域性隱藏的寬度)

[java] view plain copy print?
  1. public SlidingItemListView(Context context, AttributeSet attrs) {  
  2.     super(context, attrs);  
  3.     TypedArray typedArray = context.obtainStyledAttributes(attrs,  
  4.             R.styleable.slidingitemlistview);  
  5.     mRightViewWidth = (int) typedArray.getDimension(  
  6.             R.styleable.slidingitemlistview_right_width, 200);  
  7.     typedArray.recycle();  
  8. }  
 public SlidingItemListView(Context context, AttributeSet attrs) {
        super(context, attrs);
        TypedArray typedArray = context.obtainStyledAttributes(attrs,
                R.styleable.slidingitemlistview);
        mRightViewWidth = (int) typedArray.getDimension(
                R.styleable.slidingitemlistview_right_width, 200);
        typedArray.recycle();

    }


(2)重寫onInterceptTouchEvent()和onTouchEvent()方法,在ACTION_DOWN裡獲取mCurrentItemView,mPreItemView,mFirstX,mFirstY等。ACTION_UP裡對是否在展示做簡單的判斷,在顯示則隱藏。

[java] view plain copy print?
  1. @Override
  2.     publicboolean onInterceptTouchEvent(MotionEvent ev) {  
  3.         float lastX = ev.getX();  
  4.         float lastY = ev.getY();  
  5.         switch (ev.getAction()) {  
  6.         case MotionEvent.ACTION_DOWN:  
  7.             mIsHorizontal = null;  
  8.             mFirstX = lastX;  
  9.             mFirstY = lastY;  
  10.             int position = pointToPosition((int) mFirstX, (int) mFirstY);  
  11.             if (position >= 0) {  
  12.                 View view = getChildAt(position - getFirstVisiblePosition());  
  13.                 mPreItemView = mCurrentItemView;  
  14.                 mCurrentItemView = view;  
  15.             }  
  16.             Log.i(”TAG”“onInterceptTouchEvent—–>ACTION_DOWN”);  
  17.             break;  
  18.         case MotionEvent.ACTION_MOVE:  
  19.             break;  
  20.         case MotionEvent.ACTION_UP:  
  21.             Log.i(”TAG”“onInterceptTouchEvent—–>ACTION_UP”);  
  22.             /**點選隱藏佈局會執行MotionEvent.ACTION_UP*/
  23.             if (mIsShown) {  
  24.                 hideRightView(mCurrentItemView);  
  25.             }  
  26.             break;  
  27.         default:  
  28.             break;  
  29.         }  
  30.         returnsuper.onInterceptTouchEvent(ev);  
  31.     }  
  32.     @Override
  33.     publicboolean onTouchEvent(MotionEvent ev) {  
  34.         float lastX = ev.getX();  
  35.         float lastY = ev.getY();  
  36.         switch (ev.getAction()) {  
  37.         case MotionEvent.ACTION_DOWN:  
  38.             Log.i(”TAG”“onTouchEvent—->ACTION_DOWN”);  
  39.             break;  
  40.         case MotionEvent.ACTION_MOVE:  
  41.             float dx = lastX - mFirstX;  
  42.             float dy = lastY - mFirstY;  
  43.             Log.i(”TAG”“onTouchEvent—->ACTION_MOVE”);  
  44.             if (mIsHorizontal == null) {  
  45.                 if (!judgeScrollDirection(dx, dy)) {  
  46.                     // 沒判斷出方向
  47.                     break;  
  48.                 }  
  49.             }  
  50.             if (mIsHorizontal) {  
  51.                 if (mIsShown&&mPreItemView!=mCurrentItemView) {  
  52.                     //正在展示,前檢視不等於後檢視  
  53.                     //則隱藏前檢視
  54.                     hideRightView(mPreItemView);  
  55.                 }  
  56.                 // 在mPreItemView!=mCurrentItemView執行 顯示隱藏的寬度
  57.                 if (dx < 0 && dx > -mRightViewWidth) {  
  58.                     Log.i(”TAG”“onTouchEvent—->MOVE   -dx=” + -dx);  
  59.                     mCurrentItemView.scrollTo((int) (-dx), 0);  
  60.                 }  
  61. //               return true;
  62.             } else {  
  63.                 if (mIsShown) {  
  64.                     //豎直方向滾動
  65.                     //則隱藏前檢視
  66.                     hideRightView(mPreItemView);  
  67.                 }  
  68.             }  
  69.             break;  
  70.         case MotionEvent.ACTION_UP:  
  71.             if (mIsShown) {  
  72.                 //點選時如果有在顯示的View
  73.                 //則隱藏前檢視
  74.                 Log.i(”TAG”“MotionEvent.ACTION_UP 隱藏前檢視”);  
  75. //              hideRightView(mCurrentItemView);
  76.                 hideRightView(mPreItemView);  
  77.             }  
  78.             if (mIsHorizontal != null && mIsHorizontal) {  
  79.                 if (mFirstX - lastX > mRightViewWidth / 2) {  
  80.                     showRight(mCurrentItemView);  
  81.                 } else {  
  82.                     // 不到一半則隱藏
  83.                     hideRightView(mCurrentItemView);  
  84.                 }  
  85.                 Log.i(”TAG”“成功接管OnTouchEvent  CANCLE return TRUE”);  
  86.                  returntrue;  
  87.             }  
  88.             break;  
  89.         default:  
  90.             break;  
  91.         }  
  92.         returnsuper.onTouchEvent(ev);  
  93.     }  
  94.     /** 
  95.      * 展示隱藏的佈局 
  96.      * @param mCurrentItemView2 
  97.      */
  98.     privatevoid showRight(View mCurrentItemView2) {  
  99.         mCurrentItemView2.scrollTo(mRightViewWidth, 0);  
  100.         mIsShown = true;  
  101.     }  
  102.     /**隱藏佈局*/
  103.     privatevoid hideRightView(View mCurrentItemView2) {  
  104.         mCurrentItemView2.scrollTo(00);  
  105.         mIsShown = false;  
  106.     }  
  @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        float lastX = ev.getX();
        float lastY = ev.getY();
        switch (ev.getAction()) {
        case MotionEvent.ACTION_DOWN:
            mIsHorizontal = null;
            mFirstX = lastX;
            mFirstY = lastY;

            int position = pointToPosition((int) mFirstX, (int) mFirstY);

            if (position >= 0) {
                View view = getChildAt(position - getFirstVisiblePosition());
                mPreItemView = mCurrentItemView;
                mCurrentItemView = view;

            }
            Log.i("TAG", "onInterceptTouchEvent----->ACTION_DOWN");
            break;
        case MotionEvent.ACTION_MOVE:

            break;
        case MotionEvent.ACTION_UP:
            Log.i("TAG", "onInterceptTouchEvent----->ACTION_UP");
            /**點選隱藏佈局會執行MotionEvent.ACTION_UP*/
            if (mIsShown) {
                hideRightView(mCurrentItemView);
            }
            break;

        default:
            break;
        }

        return super.onInterceptTouchEvent(ev);
    }

    @Override
    public boolean onTouchEvent(MotionEvent ev) {

        float lastX = ev.getX();
        float lastY = ev.getY();

        switch (ev.getAction()) {
        case MotionEvent.ACTION_DOWN:
            Log.i("TAG", "onTouchEvent---->ACTION_DOWN");
            break;
        case MotionEvent.ACTION_MOVE:
            float dx = lastX - mFirstX;
            float dy = lastY - mFirstY;
            Log.i("TAG", "onTouchEvent---->ACTION_MOVE");

            if (mIsHorizontal == null) {
                if (!judgeScrollDirection(dx, dy)) {
                    // 沒判斷出方向
                    break;
                }
            }

            if (mIsHorizontal) {
                if (mIsShown&&mPreItemView!=mCurrentItemView) {
                    //正在展示,前檢視不等於後檢視  
                    //則隱藏前檢視
                    hideRightView(mPreItemView);
                }

                // 在mPreItemView!=mCurrentItemView執行 顯示隱藏的寬度
                if (dx < 0 && dx > -mRightViewWidth) {
                    Log.i("TAG", "onTouchEvent---->MOVE   -dx=" + -dx);
                    mCurrentItemView.scrollTo((int) (-dx), 0);
                }
//               return true;
            } else {
                if (mIsShown) {
                    //豎直方向滾動
                    //則隱藏前檢視
                    hideRightView(mPreItemView);
                }
            }

            break;
        case MotionEvent.ACTION_UP:
            if (mIsShown) {
                //點選時如果有在顯示的View
                //則隱藏前檢視
                Log.i("TAG", "MotionEvent.ACTION_UP 隱藏前檢視");
//              hideRightView(mCurrentItemView);
                hideRightView(mPreItemView);
            }

            if (mIsHorizontal != null && mIsHorizontal) {
                if (mFirstX - lastX > mRightViewWidth / 2) {
                    showRight(mCurrentItemView);
                } else {
                    // 不到一半則隱藏
                    hideRightView(mCurrentItemView);
                }
                Log.i("TAG", "成功接管OnTouchEvent  CANCLE return TRUE");
                 return true;
            }
            break;

        default:
            break;
        }

        return super.onTouchEvent(ev);
    }

    /**
     * 展示隱藏的佈局
     * @param mCurrentItemView2
     */
    private void showRight(View mCurrentItemView2) {
        mCurrentItemView2.scrollTo(mRightViewWidth, 0);
        mIsShown = true;
    }

    /**隱藏佈局*/
    private void hideRightView(View mCurrentItemView2) {

        mCurrentItemView2.scrollTo(0, 0);

        mIsShown = false;

    }


這裡面涉及到一個方法judgeScrollDirection,判斷滑動方向,我是這麼判斷的

[java] view plain copy print?
  1. <span style=“white-space:pre”>    </span>/** 
  2.      * @param 水平距離差 
  3.      * @param 豎直距離差 
  4.      * @return 水平滑動或者豎直滑動都返回true 沒有判斷出滑動方向則返回false 
  5.      */
  6.     privateboolean judgeScrollDirection(float dx, float dy) {  
  7.         if (Math.abs(dx) > 30 && Math.abs(dx) > Math.abs(dy) * 2) {  
  8.             mIsHorizontal = true;  
  9.             returntrue;  
  10.         }  
  11.         if (Math.abs(dy) > 30 && Math.abs(dy) > Math.abs(dx) * 2) {  
  12.             mIsHorizontal = false;  
  13.             returntrue;  
  14.         }  
  15.         returnfalse;  
  16.     }  
<span style="white-space:pre">    </span>/**
     * @param 水平距離差
     * @param 豎直距離差
     * @return 水平滑動或者豎直滑動都返回true 沒有判斷出滑動方向則返回false
     */
    private boolean judgeScrollDirection(float dx, float dy) {

        if (Math.abs(dx) > 30 && Math.abs(dx) > Math.abs(dy) * 2) {
            mIsHorizontal = true;
            return true;
        }
        if (Math.abs(dy) > 30 && Math.abs(dy) > Math.abs(dx) * 2) {
            mIsHorizontal = false;
            return true;
        }

        return false;
    }

(3)啊,最後還有一個get setRightViewWidth方法不要我忘了,後面例項化adapter時還要用
[java] view plain copy print?
  1. <span style=“white-space:pre”>    </span>publicint getRightViewWidth() {  
  2.         return mRightViewWidth;  
  3.     }  
  4.     publicvoid setRightViewWidth(int mRightViewWidth) {  
  5.         this.mRightViewWidth = mRightViewWidth;  
  6.     }  
<span style="white-space:pre">   </span>public int getRightViewWidth() {
        return mRightViewWidth;
    }

    public void setRightViewWidth(int mRightViewWidth) {
        this.mRightViewWidth = mRightViewWidth;
    }

自定義listview到此就大功告成了,是不是直接就可以使用了呢?我很負責任的告訴你:絕對不可以!adapter表示自己不樂意!

下面就來寫一個adapter吧。繼承BaseAdapter重寫getCount,getItem,getItemId,getView。當然最重要的是getView。這些比較簡單,直接貼程式碼了

[java] view plain copy print?
  1. private Context mContext;  
  2. private LayoutInflater mInflater;  
  3. private List<SlidingItembean> list;  
  4. privateint mRightViewWidth;  
  5. public SlidingItemListViewAdapter(Context mContext,  
  6.         List<SlidingItembean> list, int mRightViewWidth) {  
  7.     super();  
  8.     this.mContext = mContext;  
  9.     this.list = list;  
  10.     this.mRightViewWidth = mRightViewWidth;  
  11.     mInflater = LayoutInflater.from(mContext);  
  12. }  
  13. @Override
  14. publicint getCount() {  
  15.     // TODO Auto-generated method stub
  16.     return list.size();  
  17. }  
  18. @Override
  19. public Object getItem(int position) {  
  20.     // TODO Auto-generated method stub
  21.     return list.get(position);  
  22. }  
  23. @Override
  24. publiclong getItemId(int position) {  
  25.     // TODO Auto-generated method stub
  26.     return position;  
  27. }  
  28. @Override
  29. public View getView(int position, View convertView, ViewGroup parent) {  
  30.     ViewHolder viewHolder;  
  31.     onClick listener;  
  32.     if (convertView == null) {  
  33.         convertView = mInflater.inflate(R.layout.item_sliding_listview,  
  34.                 null);  
  35.         viewHolder = new ViewHolder();  
  36.         listener = new onClick();// 例項化
  37.         viewHolder.Re_left = (RelativeLayout) convertView  
  38.                 .findViewById(R.id.Re_left);  
  39.         viewHolder.ll_right = (LinearLayout) convertView  
  40.                 .findViewById(R.id.ll_right);  
  41.         viewHolder.num = (TextView) convertView  
  42.                 .findViewById(R.id.tv_num_Re_left);  
  43.         viewHolder.name = (TextView) convertView  
  44.                 .findViewById(R.id.tv_name_Re_left);  
  45.         viewHolder.path = (TextView) convertView  
  46.                 .findViewById(R.id.tv_path_Re_left);  
  47.         viewHolder.play = (ImageView) convertView  
  48.                 .findViewById(R.id.img_play_Re_left);  
  49.         viewHolder.setTop= (TextView) convertView.findViewById(R.id.tv_setTop);  
  50.         viewHolder.ll_delete = (LinearLayout) convertView  
  51.                 .findViewById(R.id.ll_delete_ll_right);  
  52.         viewHolder.ll_setTop = (LinearLayout) convertView  
  53.                 .findViewById(R.id.ll_setTop_ll_right);  
  54.         viewHolder.ll_setTop.setOnClickListener(listener);// 監聽
  55.         viewHolder.ll_delete.setOnClickListener(listener);// 監聽
  56.         viewHolder.play.setOnClickListener(listener);// 監聽
  57.         convertView.setTag(viewHolder.play.getId(), listener);// 設定tag
  58.         convertView.setTag(viewHolder);  
  59.     } else {  
  60.         viewHolder = (ViewHolder) convertView.getTag();  
  61.         listener = (onClick) convertView.getTag(viewHolder.play.getId());// 獲取例項
  62.     }  
  63.     listener.setPosition(position);// 傳遞position
  64.     // 設定佈局引數
  65.     LayoutParams lp_left = new LayoutParams(  
  66.             android.widget.LinearLayout.LayoutParams.MATCH_PARENT,  
  67.             android.widget.LinearLayout.LayoutParams.MATCH_PARENT);  
  68.     viewHolder.Re_left.setLayoutParams(lp_left);  
  69.     LayoutParams lp_right = new LayoutParams(mRightViewWidth,  
  70.             android.widget.LinearLayout.LayoutParams.MATCH_PARENT);  
  71.     viewHolder.ll_right.setLayoutParams(lp_right);  
  72.     SlidingItembean slidingItembean = list.get(position);  
  73.     viewHolder.num.setText(slidingItembean.getNum());  
  74.     viewHolder.name.setText(slidingItembean.getName());  
  75.     viewHolder.path.setText(slidingItembean.getPath());  
  76.     viewHolder.setTop.setText(slidingItembean.getSetTop());  
  77.     return convertView;  
  78. }  
 private Context mContext;

    private LayoutInflater mInflater;

    private List<SlidingItembean> list;

    private int mRightViewWidth;

    public SlidingItemListViewAdapter(Context mContext,
            List<SlidingItembean> list, int mRightViewWidth) {
        super();
        this.mContext = mContext;
        this.list = list;
        this.mRightViewWidth = mRightViewWidth;
        mInflater = LayoutInflater.from(mContext);
    }

    @Override
    public int getCount() {
        // TODO Auto-generated method stub
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        // TODO Auto-generated method stub
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        // TODO Auto-generated method stub
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        ViewHolder viewHolder;
        onClick listener;
        if (convertView == null) {
            convertView = mInflater.inflate(R.layout.item_sliding_listview,
                    null);
            viewHolder = new ViewHolder();
            listener = new onClick();// 例項化
            viewHolder.Re_left = (RelativeLayout) convertView
                    .findViewById(R.id.Re_left);
            viewHolder.ll_right = (LinearLayout) convertView
                    .findViewById(R.id.ll_right);
            viewHolder.num = (TextView) convertView
                    .findViewById(R.id.tv_num_Re_left);
            viewHolder.name = (TextView) convertView
                    .findViewById(R.id.tv_name_Re_left);
            viewHolder.path = (TextView) convertView
                    .findViewById(R.id.tv_path_Re_left);
            viewHolder.play = (ImageView) convertView
                    .findViewById(R.id.img_play_Re_left);
            viewHolder.setTop= (TextView) convertView.findViewById(R.id.tv_setTop);
            viewHolder.ll_delete = (LinearLayout) convertView
                    .findViewById(R.id.ll_delete_ll_right);
            viewHolder.ll_setTop = (LinearLayout) convertView
                    .findViewById(R.id.ll_setTop_ll_right);
            viewHolder.ll_setTop.setOnClickListener(listener);// 監聽
            viewHolder.ll_delete.setOnClickListener(listener);// 監聽
            viewHolder.play.setOnClickListener(listener);// 監聽
            convertView.setTag(viewHolder.play.getId(), listener);// 設定tag
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
            listener = (onClick) convertView.getTag(viewHolder.play.getId());// 獲取例項
        }

        listener.setPosition(position);// 傳遞position

        // 設定佈局引數

        LayoutParams lp_left = new LayoutParams(
                android.widget.LinearLayout.LayoutParams.MATCH_PARENT,
                android.widget.LinearLayout.LayoutParams.MATCH_PARENT);
        viewHolder.Re_left.setLayoutParams(lp_left);

        LayoutParams lp_right = new LayoutParams(mRightViewWidth,
                android.widget.LinearLayout.LayoutParams.MATCH_PARENT);
        viewHolder.ll_right.setLayoutParams(lp_right);

        SlidingItembean slidingItembean = list.get(position);
        viewHolder.num.setText(slidingItembean.getNum());
        viewHolder.name.setText(slidingItembean.getName());
        viewHolder.path.setText(slidingItembean.getPath());
        viewHolder.setTop.setText(slidingItembean.getSetTop());

        return convertView;
    }
[java] view plain copy print?
  1. staticclass ViewHolder {  
  2. RelativeLayout Re_left;  
  3. LinearLayout ll_right;  
  4. LinearLayout ll_delete;  
  5. LinearLayout ll_setTop;  
  6. TextView num;  
  7. TextView name;  
  8. TextView path;  
  9. ImageView play;  
  10. TextView setTop;  
  11.    }  
  12. }  
static class ViewHolder {


RelativeLayout Re_left;
LinearLayout ll_right;


LinearLayout ll_delete;
LinearLayout ll_setTop;


TextView num;
TextView name;
TextView path;


ImageView play;


TextView setTop;
   }


}

細心的同學可能會發現onClick 物件,listener。這個listener是幹什麼的呢?原來啊這是個繼承OnClickListener的類,目的和ViewHolder一樣,複用item。以前只是複用item控制元件,這下連監聽事件都可以複用了,嘿嘿。程式碼是不會騙人的,來看看這個Onclick類吧

[java] view plain copy print?
  1. class onClick implements OnClickListener {  
  2.     int position;  
  3.     publicvoid setPosition(int position) {  
  4.         this.position = position;  
  5.     }  
  6.     @Override
  7.     publicvoid onClick(View v) {  
  8.         switch (v.getId()) {  
  9.         case R.id.img_play_Re_left:  
  10.             Toast.makeText(mContext, ”play—>position=” + position,  
  11.                     Toast.LENGTH_SHORT).show();  
  12.             break;  
  13.         case R.id.ll_delete_ll_right:  
  14.             list.remove(position);  
  15.             SlidingItemListViewAdapter.this.notifyDataSetChanged();  
  16.             break;  
  17.         case R.id.ll_setTop_ll_right:  
  18.             if (mySetTopInterface!=null) {  
  19.                 mySetTopInterface.Onclick_ll_setTop_ll_right(v,position);  
  20.             }else {  
  21.                 Toast.makeText(mContext, ”mySetTopInterface==null”,  
  22.                         Toast.LENGTH_SHORT).show();  
  23.             }  
  24.             break;  
  25.         default:  
  26.             break;  
  27.         }  
  28.     }  
  29. }  
   class onClick implements OnClickListener {

        int position;

        public void setPosition(int position) {
            this.position = position;
        }

        @Override
        public void onClick(View v) {
            switch (v.getId()) {
            case R.id.img_play_Re_left:
                Toast.makeText(mContext, "play--->position=" + position,
                        Toast.LENGTH_SHORT).show();
                break;
            case R.id.ll_delete_ll_right:
                list.remove(position);
                SlidingItemListViewAdapter.this.notifyDataSetChanged();

                break;
            case R.id.ll_setTop_ll_right:

                if (mySetTopInterface!=null) {
                    mySetTopInterface.Onclick_ll_setTop_ll_right(v,position);
                }else {
                    Toast.makeText(mContext, "mySetTopInterface==null",
                            Toast.LENGTH_SHORT).show();
                }

                break;

            default:
                break;
            }

        }
    }

這裡用到了一個自己定義的介面MySetTopInterface,作用顯而易見,設定置頂的時候呼叫此介面,傳遞兩個引數,一個是被點選的View,另一個是position。

[java] view plain copy print?
  1. MySetTopInterface mySetTopInterface;  
  2.     publicinterface MySetTopInterface {  
  3.         void Onclick_ll_setTop_ll_right(View view,int position);  
  4.     }  
  5.     publicvoid setMySetTopInterface(MySetTopInterface mySetTopInterface) {  
  6.         this.mySetTopInterface = mySetTopInterface;  
  7.     }  
MySetTopInterface mySetTopInterface;

    public interface MySetTopInterface {
        void Onclick_ll_setTop_ll_right(View view,int position);
    }

    public void setMySetTopInterface(MySetTopInterface mySetTopInterface) {
        this.mySetTopInterface = mySetTopInterface;
    }
adapter表示自己作用已完成,等待領導指示!

領導表示listview的item佈局忘貼上來了,,,
下面貼item_sliding_listview佈局,,,

[html] view plain copy print?
  1. <?xmlversion=“1.0”encoding=“utf-8”?>
  2. <LinearLayoutxmlns:android=“http://schemas.android.com/apk/res/android”
  3.     android:layout_width=“match_parent”
  4.     android:layout_height=“55dp”
  5.     android:background=“#fff”
  6.     android:orientation=“horizontal”>
  7.     <RelativeLayout
  8.         android:id=“@+id/Re_left”
  9.         android:layout_width=“match_parent”
  10.         android:layout_height=“match_parent”>
  11.         <TextView
  12.             android:id=“@+id/tv_num_Re_left”
  13.             android:layout_width=“20dp”
  14.             android:layout_height=“20dp”
  15.             android:layout_centerVertical=“true”
  16.             android:layout_marginLeft=“10dp”
  17.             android:layout_marginRight=“10dp”
  18.             android:background=“@drawable/tv_num_bg”
  19.             android:gravity=“center”
  20.             android:text=“1”
  21.             android:textColor=“#fff”
  22.             android:textSize=“12sp”/>
  23.         <RelativeLayout
  24.             android:layout_width=“match_parent”
  25.             android:layout_height=“wrap_content”
  26.             android:layout_centerVertical=“true”
  27.             android:layout_toRightOf=“@id/tv_num_Re_left”>
  28.             <TextView
  29.                 android:id=“@+id/tv_name_Re_left”
  30.                 android:layout_width=“match_parent”
  31.                 android:layout_height=“wrap_content”
  32.                 android:layout_marginBottom=“5dp”
  33.                 android:text=“《好久不見》”
  34.                 android:textColor=“#000”
  35.                 android:textSize=“16sp”/>
  36.             <TextView
  37.                 android:id=“@+id/tv_path_Re_left”
  38.                 android:layout_width=“match_parent”
  39.                 android:layout_height=“wrap_content”
  40.                 android:layout_below=“@id/tv_name_Re_left”
  41.                 android:text=“/var/mobile/Contalners/Application”
  42.                 android:textSize=“10sp”/>
  43.         </RelativeLayout>
  44.         <ImageView
  45.             android:id=“@+id/img_play_Re_left”
  46.             android:layout_width=“30dp”
  47.             android:layout_height=“30dp”
  48.             android:layout_alignParentRight=“true”
  49.             android:layout_centerVertical=“true”
  50.             android:layout_marginRight=“10dp”
  51.             android:scaleType=“fitXY”
  52.             android:src=“@drawable/wechat_icon”/>
  53.     </RelativeLayout>
  54.     <LinearLayout
  55.         android:id=“@+id/ll_right”
  56.         android:layout_width=“wrap_content”
  57.         android:layout_height=“match_parent”
  58.         android:orientation=“horizontal”>
  59.         <LinearLayout
  60.             android:id=“@+id/ll_delete_ll_right”
  61.             android:layout_width=“0dp”
  62.             android:layout_height=“match_parent”
  63.             android:layout_weight=“1”
  64.             android:background=“#F77D48”
  65.             android:gravity=“center”
  66.             android:orientation=“vertical”
  67.             android:padding=“5dp”>
  68.             <ImageView
  69.                 android:layout_width=“30dp”
  70.                 android:layout_height=“30dp”
  71.                 android:scaleType=“fitXY”
  72.                 android:src=“@drawable/del_icon_normal”/>