2012-03-05 10 views
0

保存ボタンをクリックするとonClickメソッドを実行できません。 これは、保存ボタンを実行したり、太陽の活動アクティビティグループのボタンが太陽の下で動作しないアクティビティ

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の onclickのミースは実行できません。..

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デバイス上のFragmentをDonut(Android 1.6)に戻すことができます。詳細については、http://developer.android.com/guide/topics/fundamentals/fragments.htmlを参照してください。

+0

ActivityGroupを使用する必要がある場合はどうすればよいですか? – user1241763

+0

まず、廃止予定のAPIを使用するように固定された理由があるのか​​どうかを尋ねることから始めます。 :-) – Sparky

+0

おそらく、この回答に引用されているブログ記事が役に立ちます。 http://stackoverflow.com/questions/4568468/activitygroup-example – Sparky

関連する問題