我有以下活动组
public class ActivityStack extends ActivityGroup{
public static int settingsFlag=0;
private Stack<String> stack;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (stack == null)
stack = new Stack<String>();
// start default activity
settingsFlag=1;
push("FirstStackActivity", new Intent(this, ChannelsActivity.class));
}
@Override
public void finishFromChild(Activity child) {
pop();
}
@Override
public void onBackPressed() {
pop();
}
public void push(String id, Intent intent) {
Window window = getLocalActivityManager().startActivity(id, intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP));
if (window != null) {
stack.push(id);
setContentView(window.getDecorView());
}
}
public void pop() {
if (stack.size() == 1)
{
if (getParent() instanceof MainActivity) {
((MainActivity) getParent()).changeToMainTabs();
}
} else {
LocalActivityManager manager = getLocalActivityManager();
manager.destroyActivity(stack.pop(), true);
if (stack.size() > 0) {
Intent lastIntent = manager.getActivity(stack.peek()).getIntent();
Window newWindow = manager.startActivity(stack.peek(), lastIntent);
setContentView(newWindow.getDecorView());
}
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu)
{
//what is the current activity?
menu.add(0, 0, 0, "holder");
return true;
}
@Override
public boolean onPrepareOptionsMenu(Menu menu)
{
//start a new
menu.clear();
//add some menu options
getLocalActivityManager().getCurrentActivity().onPrepareOptionsMenu(menu);
return super.onPrepareOptionsMenu(menu);
}
}
我在另一个活动中有这段代码:
editTxt.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
Intent countryIntent = new Intent();
countryIntent.setClass(getParent(),Test.class);
//startActivityForResult(countryIntent, requestCode);
ActivityStack activityStack = (ActivityStack) getParent();
**activityStack.push("SecondActivity", startActivityForResult(countryIntent, requestCode)); //!!THIS SI NOW WORKING CASE IT EXPECTS AN INTENT**
}
});
我怎样才能使这项工作?有人可以帮忙吗?