0

when I click save button, onClick method can't run. this is a ActivityGroup.I holp the save button can run or listen in sun activity

public class DisasterActivity extends ActivityGroup {
RadioGroup radioGroup;
RadioButton tab_mydisaster;
RadioButton tab_upload;
RadioButton tab_view;
FrameLayout container;
Button save;

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.disaster);
    initview();
    setClick();
    container.addView(getLocalActivityManager().startActivity("mydisaster",
            new Intent(this, MyDisaster.class)).getDecorView());
}

void initview() {
    radioGroup = (RadioGroup) findViewById(R.id.tab);
    tab_mydisaster = (RadioButton) findViewById(R.id.tab_mydisaster);
    tab_upload = (RadioButton) findViewById(R.id.tab_upload);
    tab_view = (RadioButton) findViewById(R.id.tab_view);
    container = (FrameLayout) findViewById(R.id.container);
    save = (Button) findViewById(R.id.save);
}

void setClick() {
    radioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(RadioGroup group, int checkedId) {
            // TODO Auto-generated method stub
            LocalActivityManager manager = getLocalActivityManager();
            Window window = null;
            Intent intent = null;
            container.removeAllViews();
            switch (checkedId) {
            case R.id.tab_mydisaster:
                intent = new Intent(DisasterActivity.this, MyDisaster.class);
                window = manager.startActivity("mydisaster", intent);
                break;
            case R.id.tab_upload:
                intent = new Intent(DisasterActivity.this, UpLoadImg.class);
                window = manager.startActivity("uploadimg", intent);
                break;
            case R.id.tab_view:
                intent = new Intent(DisasterActivity.this,
                        ViewBriefActivity.class);
                window = manager.startActivity("viewbreaf", intent);
                break;
            }
            container.addView(window.getDecorView());
        }
    });
}

}

The Button of ActivityGroup don't work in sun Activity. onclick meath of save.setOnClickListener can't run..

 public class MyDisaster extends Activity{
ActivityGroup parent;
Button save;
@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.data_manage);
    parent=(ActivityGroup)getParent();
    save=(Button)parent.findViewById(R.id.save);
    save.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            Toast.makeText(parent, "Test", Toast.LENGTH_SHORT).show();
        }
    });
}

}

user1241763
  • 59
  • 1
  • 3

1 Answers1

0

ActivityGroup is deprecated. Please consider just abandoning your ActivityGroup implementation and use Fragments instead. You can support Fragments on Android devices going back to Donut (Android 1.6) by linking android-support-v4.jar. For more information, please see http://developer.android.com/guide/topics/fundamentals/fragments.html.

Sparky
  • 8,437
  • 1
  • 29
  • 41