設定したメイン アクティビティ グループから開始する子アクティビティを設定しようとしています。
アクティビティ グループを初めて使用するので、設定に問題があります。
4 つのラジオ ボタンが設定されています。それぞれのボタンで MainActivity から子アクティビティを開きたいと思います。
「OpenCategories をタイプに解決できません」および「メソッド startChildActivity(String, Intent) はタイプ Categories に対して定義されていません」というエラーが表示されます。
私はここで何か間違ったことをしていることを知っているので、これを設定するためのガイダンスが必要です.
主な活動:
import java.util.ArrayList;
import android.app.ActivityGroup;
import android.content.Intent;
import android.os.Bundle;
import android.view.Window;
import android.widget.CompoundButton;
import android.widget.GridView;
import android.widget.RadioButton;
import android.widget.RelativeLayout;
import android.widget.Toast;
public class MainActivity extends ActivityGroup {
private ArrayList<String> mIdList;
GridView list;
LazyAdapter adapter;
@Override
public void onCreate(Bundle savedInstanceState) {
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
list = (GridView) findViewById(R.id.list);
adapter = new LazyAdapter(this, mStrings);
list.setAdapter(adapter);
RadioButton btnAll = (RadioButton) findViewById(R.id.btnAll);
btnAll.setOnCheckedChangeListener(btnAllOnCheckedChangeListener);
RadioButton btnCategories = (RadioButton) findViewById(R.id.btnCategories);
btnCategories
.setOnCheckedChangeListener(btnCategoriesOnCheckedChangeListener);
RadioButton btnPopular = (RadioButton) findViewById(R.id.btnPopular);
btnPopular
.setOnCheckedChangeListener(btnPopularOnCheckedChangeListener);
RadioButton btnAbout = (RadioButton) findViewById(R.id.btnAbout);
btnAbout.setOnCheckedChangeListener(btnAboutOnCheckedChangeListener);
}
public void startChildActivity(String Id, Intent intent) {
Window window = getLocalActivityManager().startActivity(Id,intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP));
if (window != null) {
mIdList.add(Id);
setContentView(window.getDecorView());
}
}
private CompoundButton.OnCheckedChangeListener btnAllOnCheckedChangeListener = new CompoundButton.OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) {
if (isChecked) {
}
}
};
private CompoundButton.OnCheckedChangeListener btnCategoriesOnCheckedChangeListener = new CompoundButton.OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) {
if (isChecked) {
//Getting error here
Intent OpenCategories = new Intent(getParent(), Categories.class);
OpenCategories.putExtra("Flag", 1);
OpenCategories = (OpenCategories)getParent();
Categories.startChildActivity("YOUR_ID", OpenCategories);
}
}
};
private CompoundButton.OnCheckedChangeListener btnPopularOnCheckedChangeListener = new CompoundButton.OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) {
if (isChecked) {
Toast.makeText(getApplicationContext(), "Opened POPULAR tab",
Toast.LENGTH_SHORT).show();
}
}
};
private CompoundButton.OnCheckedChangeListener btnAboutOnCheckedChangeListener = new CompoundButton.OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) {
if (isChecked) {
Toast.makeText(getApplicationContext(), "Opened ABOUT tab",
Toast.LENGTH_SHORT).show();
}
}
};
@Override
public void onDestroy() {
list.setAdapter(null);
super.onDestroy();
}
private String[] mStrings = {
"www.LOTSOFURLSHERE.com", };
};