开发者

how to close an activity inside activity group?

I have an activity group which contains 2 activities. From first activity I goto the 2nd. I have a close button inside my 2nd activity. When I do a close over there, I should close that 2nd activity and the first activity shou开发者_Python百科ld come with the data which it had earlier. That means I cant call intent to the 1st activity while doing close. Because then the data in 1st activity will change. How can I do this?


I got it worked. Inside the activity group class,give the following code:

    RelativeLayout landingLayout = (RelativeLayout) findViewById(R.id.landingLayout);
    private static ArrayList<View> history;
    history = new ArrayList<View>();

    if (history.size() > 1) {
        history.remove(history.size() - 1);
        View view = history.get(history.size() - 1);
        replaceLandingView(view);
    } else {
        finish();
    }

    protected void replaceLandingView(View view) {
        landingLayout.removeAllViews();
        RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
                LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
        landingLayout.addView(view, params);
    }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜