0

Toggle button用来调用 other activity,并使用我们与普通 android 按钮一起使用的代码来调用另一个活动,如下所示:

toggleButton.setOnCheckedChangeListener(new OnCheckedChangeListener() {

            @Override
            public void onCheckedChanged(CompoundButton arg0, boolean isChecked) {

                textMap.setText("Status: " + isChecked);
                String strMapStatus = textMap.getText().toString();
                Toast.makeText(TrackerActivity.this, strMapStatus, Toast.LENGTH_LONG).show();

                if(strMapStatus.equalsIgnoreCase("true"))
                {
                    Bundle bundle = new Bundle();
                    bundle.putSerializable("viewall",arrayList);
                    Intent sendtosecond = new Intent(TrackerActivity.this, MapActivity.class);
                    sendtosecond.putExtra("bundle", bundle);
                    startActivity(sendtosecond);
                }

            }
        });

我将检查状态设为“true”和“false”,Toast但无法调用MapActivity

4

1 回答 1

1

代替

if(strMapStatus.equalsIgnoreCase("true"))

if(isChecked)
于 2015-01-03T11:14:21.273 回答