zoukankan      html  css  js  c++  java
  • 一手遮天 Android

    项目地址 https://github.com/webabcd/AndroidDemo
    作者 webabcd

    一手遮天 Android - view(自定义): 自定义圆形带进度提示的 loading 控件

    示例如下:

    /view/custom/MyLoadingDemo1.java

    /**
     * 开发一个自定义圆形带进度提示的 loading 控件
     *
     * 参见 view/custom/MyLoading1.java
     */
    
    package com.webabcd.androiddemo.view.custom;
    
    import androidx.appcompat.app.AppCompatActivity;
    import android.os.Bundle;
    import android.os.SystemClock;
    
    import com.webabcd.androiddemo.R;
    
    public class MyLoadingDemo1 extends AppCompatActivity {
    
        private MyLoading1 myLoading1;
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_view_custom_myloadingdemo1);
    
            myLoading1 = findViewById(R.id.myLoading1);
    
            sample();
        }
    
        private void sample() {
            Thread thread = new Thread(new Runnable() {
                @Override
                public void run() {
                    int progress = 0;
                    while (true) {
                        // 更新当前进度值
                        myLoading1.setProgress(progress);
                        progress++;
    
                        if (progress > 100) {
                            break;
                        }
    
                        SystemClock.sleep(50);
                    }
                }
            });
            thread.setName("thread_MyLoadingDemo1");
            thread.setDaemon(true);
            thread.start();
        }
    }
    
    

    /layout/activity_view_custom_myloadingdemo1.xml

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">
    
        <com.webabcd.androiddemo.view.custom.MyLoading1
            android:id="@+id/myLoading1"
            android:layout_width="match_parent"
            android:layout_height="match_parent"/>
    
    </LinearLayout>
    
    

    项目地址 https://github.com/webabcd/AndroidDemo
    作者 webabcd

  • 相关阅读:
    域运算符::
    类和结构体类型的异同
    4 链表组件(817)
    2 旋转链表(61)
    1、重排链表(力扣143)
    子字符串排序的关键代码
    C语言四舍五入
    约分
    python学习第八天
    python学习第七天
  • 原文地址:https://www.cnblogs.com/webabcd/p/android_view_custom_MyLoadingDemo1.html
Copyright © 2011-2022 走看看