2012-03-05 2 views
0

저장 버튼을 클릭하면 onClick 메서드를 실행할 수 없습니다. 이 저장 버튼을 실행하거나 태양 활동ActivityGroup의 버튼이 태양에서 작동하지 않습니다.

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()); 
     } 
    }); 
} 

}에서들을 수 ActivityGroup.I의 holp입니다

ActivityGroup의 버튼은 태양 활동에서 작동하지 않습니다. save.setOnClickListener의 온 클릭 미스를 실행할 수 없습니다 ..

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(); 
     } 
    }); 
} 

}

답변

0

ActivityGroup가되지 않습니다. ActivityGroup 구현을 포기하고 대신 Fragments을 사용하십시오. Android-support-v4.jar를 연결하여 도넛 형 (Android 1.6)으로 돌아가는 Android 기기에서 단편을 지원할 수 있습니다. 자세한 내용은 http://developer.android.com/guide/topics/fundamentals/fragments.html을 참조하십시오.

+0

ActivityGroup을 사용해야하는 경우 어떻게해야합니까? – user1241763

+0

더 이상 사용되지 않는 API를 사용해야하는 이유는 무엇입니까? :-) – Sparky

+0

아마도이 답변에 인용 된 블로그 기사가 도움이 될 수 있습니다. http://stackoverflow.com/questions/4568468/activitygroup-example – Sparky

관련 문제