短視訊軟體開發,按鈕側滑顯示各個選項

zhibo系統開發發表於2022-05-04

短視訊軟體開發,按鈕側滑顯示各個選項

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    xmlns:android="
    android:layout_marginTop="10dp">
    <TextView
        android:id="@+id/SideText"
        android:layout_width="100dp"
        android:layout_height="60dp"
        android:text="選擇車位"
        android:textSize="15sp"
        android:background="#DD2248"
        android:gravity="center"
        android:textColor="#ffffff"
        android:layout_marginRight="10dp"
        android:layout_centerInParent="true"
        android:layout_alignParentRight="true"/>
    <!--大-->
    <LinearLayout
        android:id="@+id/SideLayout"
        android:layout_width="match_parent"
        android:layout_height="70dp"
        android:orientation="horizontal"
        android:background="@drawable/btn_style"
        android:gravity="center"
        android:padding="10dp">
        <!--小-->
        <LinearLayout
            android:layout_weight="1"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:layout_marginLeft="5dp">
            <TextView
                android:id="@+id/SimplePlace"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="工人文化宮停車場"
                android:textColor="#000000"
                android:textSize="15sp"
                android:singleLine="true"
                android:ellipsize="end"
                />
            <TextView
                android:id="@+id/detailPlace"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="田心大道52號附件"
                android:textSize="10sp"
                android:layout_marginTop="10dp"
                android:singleLine="true"
                android:ellipsize="end"
                />
        </LinearLayout>
        <!--小-->
        <LinearLayout
            android:layout_weight="1"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:layout_marginLeft="10dp"
            android:layout_gravity="center"
            android:gravity="center">
            <ImageView
                android:id="@+id/ParkingIcon"
                android:layout_width="30dp"
                android:layout_height="30dp"
                android:src="@drawable/road_sign"
                android:scaleType="fitCenter"/>
            <TextView
                android:id="@+id/ParkingDistance"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="201m"
                android:textSize="10sp" />
        </LinearLayout>
        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:layout_gravity="center"
            android:gravity="center">
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="空餘車位:"
                android:textColor="#000000"
                android:textSize="15sp"/>
            <TextView
                android:id="@+id/ParkingNumber"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="10個"
                android:textColor="#ff0000"
                android:textSize="15sp"/>
        </LinearLayout>
    </LinearLayout>
</RelativeLayout>


應用

解析xml資料

private void InitData(){
        String[] parkingArray = getResources().getStringArray(R.array.parking);
        for (int i = 0; i <parkingArray.length ; i+=4) {
            ParkingData data = new ParkingData(parkingArray[i],parkingArray[i+1],parkingArray[i+2],Integer.parseInt(parkingArray[i+3]));
            dataList.add(data);
        }
    }

繫結

WeSwipe.attach(ParkingRecycler);

private void InitRecycler(){
        LinearLayoutManager manager = new LinearLayoutManager(this);
        ParkingRecycler.setLayoutManager(manager);
        adapter = new ParkingAdapter(dataList);
        ParkingRecycler.setAdapter(adapter);
        WeSwipe.attach(ParkingRecycler);
    }

點選事件引用

adapter.setOnclick(new ParkingAdapter.ParkingOnClick() {
            @Override
            public void OnClickListener(View view, int Position) {
               //do anything...
            }
        });


以上就是 短視訊軟體開發,按鈕側滑顯示各個選項,更多內容歡迎關注之後的文章


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/69978258/viewspace-2890664/,如需轉載,請註明出處,否則將追究法律責任。

相關文章