android - 安卓代码执行流程问题
伊谢尔伦
伊谢尔伦 2017-04-18 09:14:37
0
1
379

在代码执行到某一处会弹出一个NumberPicker,我希望在NumberPick选中值后再继续执行下面的代码,请问该怎么做呢,印象里有什么锁来着,行不行呢,下面是代码,麻烦大家帮忙看看,谢谢


        autoClean.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked){
                    alert.setTitle("选择清理间隔(时)");
                    alert.show();            //这里弹出了对话框,我希望后面的代码在对话框点击了下面的确定按钮后执行,并且下面的代码不要写到确定按钮的监听器下
                    Log.d("TAG","fuck");
                    Intent intent = new Intent(ProccessesActivity.this,AutoCleanService.class);
                    getApplicationContext().startService(intent);
                }else {

                }
            }
        });

        confirmTimeButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                SharedPreferences.Editor sharedPreferences=getSharedPreferences("data",MODE_PRIVATE).edit();
                sharedPreferences.putInt("autoCleanTime",numberPicker.getValue());
                sharedPreferences.commit();
                Log.d("TAG","changed");
                alert.dismiss();
            }
        });
伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

reply all(1)
阿神

Alert monitoring is definitely required. Either it is a callback when the button above the alert is clicked, or it is a callback to monitor the closing of the alert, which is determined according to the business.
As for the following code, you can place it elsewhere and make two callbacks. That’s it, just like:

alert.setListener(new Listener(){
    public void onXXX(){
        //如果你不喜欢在这里写代码可以在这里做一个2次回调.到其他地方.或者用变量.
    }
});
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template