两个活动的通用布局 - Android

时间:2014-04-14 02:54:24

标签: android visibility

我如何为两个类提供一个单一的XML?我想从另一个班级打电话给我,任何帮助都会受到高度赞赏!

    progressBar1 = (ProgressBar) findViewById(R.id.progressBar1);
    progressBar2 = (ProgressBar) findViewById(R.id.progressBar2);
    checkBox1 = (CheckBox) findViewById(R.id.checkBox1);
    checkBox2 = (CheckBox) findViewById(R.id.checkBox2);

    checkBox1.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            updateProgressBars();
        }
    });

    checkBox2.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            updateProgressBars();
        }
    });
    }

    public void updateProgressBars() {

      progressBar1.setVisibility(View.GONE);
      progressBar2.setVisibility(View.GONE);

     if (checkBox1.isChecked() && checkBox2.isChecked()) {
        progressBar2.setVisibility(View.VISIBLE);
     } else if (checkBox1.isChecked()) {
        progressBar1.setVisibility(View.VISIBLE);
     }

0 个答案:

没有答案
相关问题