【问题标题】:Maintaining the SeekBar with the File Progress使用文件进度维护 SeekBar
【发布时间】:2012-08-09 10:04:51
【问题描述】:

我想将 SeekBar 与文件的解压缩 (UnZip) 一起维护。

SeekBar 需要从文件的 UnZip 开始,并在 .zip 文件的解压缩过程完成后结束。

已通过 Google 搜索,但找不到我要查找的内容。

谢谢, 大卫布朗

【问题讨论】:

    标签: android zip unzip seekbar compression


    【解决方案1】:

    你可以做这样的事情。 后台进程使用AsyncTask。解压进度可以设置为 seekBar 如下。希望这会有所帮助。

    class SampleTask extends AsyncTask<Void, Integer, String>
    {
        private Context context = null;
    
        public SampleTask(Context context) 
        {
            this.context = context;         
        }
    
        @Override
        protected void onPreExecute() 
        {
            super.onPreExecute();
        }
    
        @Override
        protected String doInBackground(Void... params) 
        {
            try
            {
                //do file decompression here
                   publishProgress(progress);
            }
            catch(Exception exception) 
            {
                exception.printStackTrace();
            }
            return null;
        }
    
        @Override
        protected void onProgressUpdate(Integer... values) 
        {
            super.onProgressUpdate(values);
            System.out.println(" --- onProgressUpdate --- "+values[0]);
            seekBar.setProgress(values[0]);
        }
    
        @Override
        protected void onCancelled() 
        {
            super.onCancelled();
            isTrue = false;
            sampleTask = null;
            System.out.println(" --- onCancelled --- "+isTrue);
        }
    
        @Override
        protected void onPostExecute(String result) 
        {
            super.onPostExecute(result);
        }       
    }
    

    编辑:查看以下链接。

    Unzip a zipped file on sd card in Android application

    How to unzip files programmatically in Android?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-04-05
      • 1970-01-01
      • 2011-06-19
      • 2012-04-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多