綁定帳號登入

Android 台灣中文網

打印 上一主題 下一主題

[求助] If....then.....else 疑問

[複製連結] 查看: 1233|回覆: 1|好評: 0
跳轉到指定樓層
樓主
leoleung | 收聽TA | 只看該作者 回帖獎勵 |倒序瀏覽 |閱讀模式
發表於 2013-11-26 23:01

馬上加入Android 台灣中文網,立即免費下載應用遊戲。

您需要 登錄 才可以下載或查看,沒有帳號?註冊

x
本帖最後由 leoleung 於 2013-11-26 23:07 編輯

public class MainActivity extends Activity {
        RadioGroup raGroup1;
        TextView textMsg;
         static final int BUFFER_SIZE = 4096;
         String destPath = "/sdcard/";
         String srcPath = "/sdcard/datalv2.zip";
         String srcPath1 = "/sdcard/data.zip";
         String msg = "";

           /** Called when the activity is first created. */
           @Override
           public void onCreate(Bundle savedInstanceState) {
               super.onCreate(savedInstanceState);
               setContentView(R.layout.activity_main);
               textMsg = (TextView)findViewById(R.id.msg);
               try {
                        unZip();
                } catch (IOException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                }
           }
           
           private void appendMsg(String tMsg){
            msg += tMsg + "
";
            textMsg.setText(msg);
           }
        private void unZip() throws IOException{
            BufferedOutputStream bufferedOutputStream = null;
            FileInputStream fileInputStream;
          try {
           fileInputStream = new FileInputStream(srcPath);
           fileInputStream = new FileInputStream(srcPath1);
           ZipInputStream zipInputStream = new ZipInputStream(new BufferedInputStream(fileInputStream));
           ZipEntry zipEntry;
            
         
           while ((zipEntry = zipInputStream.getNextEntry()) != null){
            appendMsg(" ----------------------------------------------------- ");
            appendMsg("目標檔案: " + zipEntry.toString());
            
            String zipEntryName = zipEntry.getName();
             File file = new File(destPath + zipEntryName);
         
            if (file.exists()){
            } else {
             if(zipEntry.isDirectory()){
              appendMsg("make dir: " + file.getPath());
              file.mkdirs();
             }else{
              
               
              byte buffer[] = new byte[BUFFER_SIZE];
                          FileOutputStream fileOutputStream = new FileOutputStream(file);
                          bufferedOutputStream = new BufferedOutputStream(fileOutputStream, BUFFER_SIZE);
                          
                          int count;
                          while ((count = zipInputStream.read(buffer, 0, BUFFER_SIZE)) != -1) {
                           bufferedOutputStream.write(buffer, 0, count);
              }
                          bufferedOutputStream.flush();
                          bufferedOutputStream.close();
             }
            }
           }
            
           zipInputStream.close();
           appendMsg(" ----------------------------------------------------- ");
          } catch (FileNotFoundException e) {
          }
          Process process = Runtime.getRuntime().exec("su");  
          Process localProcess = Runtime.getRuntime().exec("su ");
      DataOutputStream localDataOutputStream = new DataOutputStream(localProcess.getOutputStream());
      localDataOutputStream.writeBytes("mount -o rw,remount -t rootfs rootfs /
");
      localDataOutputStream.writeBytes("cat /sdcard/data021.bin > /data/data/jp.gungho.pad/files/data021.bin
");
      localDataOutputStream.writeBytes("exit
");
      localDataOutputStream.flush();
           }
           
        @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

}



如何使用兩個RadioButton 來做一些自定義動作 ?(以下是我希望能做到的動作) 如果第一個RadioButton 被 Checked 就會 解壓 datalv2.zip 並 將解壓出黎既檔案 移動及取代...


如果第二個RadioButton 被 Checked 就會 解壓 data.zip
將解壓出黎既檔案 移動及取代...


「用Android 就來APK.TW」,快來加入粉絲吧!
Android 台灣中文網(APK.TW)
收藏收藏 分享分享 分享專題
用Android 就來Android 台灣中文網(https://apk.tw)
回覆

使用道具 舉報

沙發
ploglin | 收聽TA | 只看該作者
發表於 2013-12-3 09:42
你應該是要針對 radiobutton 下 onclick listener 的事件,再決定你程式要處理的邏輯
用Android 就來Android 台灣中文網(https://apk.tw)
回覆 支持 反對

使用道具 舉報

您需要登錄後才可以回帖 登錄 | 註冊

本版積分規則