Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android studio 如何制作下载按钮,下载pdf等文件。。。在安卓研究中_Android Studio_Button_Download - Fatal编程技术网

Android studio 如何制作下载按钮,下载pdf等文件。。。在安卓研究中

Android studio 如何制作下载按钮,下载pdf等文件。。。在安卓研究中,android-studio,button,download,Android Studio,Button,Download,我正在制作一个应用程序,我想在其中下载按钮,让用户下载我的文件。那么,我如何制作这样的按钮呢?这是两个Qestion… 因此,首先需要一个普通按钮[在LayoutFile.yml中执行此操作] <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/activity_

我正在制作一个应用程序,我想在其中下载按钮,让用户下载我的文件。那么,我如何制作这样的按钮呢?

这是两个Qestion…
因此,首先需要一个普通按钮[在LayoutFile.yml中执行此操作]

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/activity_test"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <Button
        android:id="@+id/button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="198dp"
        android:text="Download" />
</RelativeLayout>
希望这有帮助:)

创建无效下载文件(URI)您必须使用URI示例-

    DownloadManager downloadManager = (DownloadManager) 
getActivity().getSystemService(Context.DOWNLOAD_SERVICE);

        DownloadManager.Request request = new DownloadManager.Request(uri);

        request.setTitle("your tittle");
        request.setDescription("your description");
        request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);


        Long reference = downloadManager.enqueue(request);
在最后一组中,单击方法并写入

Uri urifile = Uri.parse("your file address");
downloadfile(urifile);

从你的服务器下载文件?是的。。来自我的服务器的文件@Gadget Guru也需要下载代码吗?@GadgetGuru在这里您可以找到如何下载
Uri urifile = Uri.parse("your file address");
downloadfile(urifile);