.模拟文件拷贝:

Posted 一个不愿透漏姓名的朝阳群众叫旺仔

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了.模拟文件拷贝:相关的知识,希望对你有一定的参考价值。

package com.hanqi.testapp22;

        import android.app.ProgressDialog;
        import android.os.Bundle;
        import android.os.Message;
        import android.support.v7.app.AppCompatActivity;
        import android.view.View;
        import android.widget.TextView;
        import android.widget.Toast;

        import android.os.Handler;

public class lianxiActivity extends AppCompatActivity {
    TextView tv_2;
    Handler h =new Handler()
    {
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            if (msg.what == 1) {
                String m = msg.obj.toString();
                tv_2.setText(tv_2.getText() + "" + m);
            }
        }
    };
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_lianxi);
        tv_2=(TextView)findViewById(R.id.tv_2);

    }
    public void bt1_OnClick(View v)
    {
        final ProgressDialog progressDialog=new ProgressDialog(this);
        progressDialog.setTitle("拷贝进度");
        progressDialog.setMessage("拷贝中...");
        progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
        progressDialog.show();
        final TextView tv_1=(TextView)findViewById(R.id.tv_1);
        new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i=1;i<=100;i++)
                {
                    progressDialog.setProgress(i);
                    try {
                        Thread.sleep(200);
                    }catch (Exception e)
                    {
                        e.printStackTrace();
                    }
                }

                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        tv_1.setText("拷贝完成");
                    }
                });
                progressDialog.dismiss();
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        Toast.makeText(lianxiActivity.this, "拷贝完成", Toast.LENGTH_SHORT).show();
                    }
                });
            }
        }).start();
    }
    public void bt2_OnClick(View v)
    {
        final ProgressDialog p=new ProgressDialog(this);
        p.setTitle("拷贝进度");
        p.setMessage("拷贝中...");
        p.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
        p.show();

        new Thread(){
            @Override
            public void run() {
                for (int i=1;i<=100;i++)
                {
                    p.setProgress(i);
                    try {
                        Thread.sleep(200);
                    }catch (Exception e)
                    {
                        e.printStackTrace();
                    }
                }

                p.dismiss();
                Message m =Message.obtain();
                m.what=1;
                m.obj="拷贝完成";
                h.sendMessage(m);

            }
        }.start();
    }
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.hanqi.testapp22.lianxiActivity"
    android:orientation="vertical">
    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/bt_1"
        android:onClick="bt1_OnClick"
        android:text="水平进度对话框和子线程模拟拷贝进度"/>
    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/tv_1"/>
    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/bt_2"
        android:onClick="bt2_OnClick"
        android:text="水平进度对话框和子线程模拟拷贝进度"/>
    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/tv_2"/>

</LinearLayout>
View Code

以上是关于.模拟文件拷贝:的主要内容,如果未能解决你的问题,请参考以下文章

Android 逆向修改运行中的 Android 进程的内存数据 ( 运行环境搭建 Android 模拟器安装 | 拷贝 Android 平台可执行文件和动态库到 /data/system )(代码片

Android——模拟文件拷贝

1.模拟文件拷贝:

.模拟文件拷贝:

Gradle 引入本地定制 jar 包

模拟拷贝文件动画显示编程只需两行中文文字即可完成