Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to change the right part dynamically #5

Closed
lynn8570 opened this issue Jul 12, 2012 · 5 comments
Closed

how to change the right part dynamically #5

lynn8570 opened this issue Jul 12, 2012 · 5 comments

Comments

@lynn8570
Copy link

This project is great, and the example shows how to extend the sliding activity.
But I am still confused about how to start another normal activity so that it would appear in the right part. For example, the left menu lists "activity1,activity2,activity3“, when the users click on the menu list, the activity
starts accordingly and the menu becomes invisible at the same time.

@jfeinstein10
Copy link
Owner

Thanks :)
The way you would do the behavior you're describing is with Fragments, not Activities.
Basically you assign a Fragment to each item in the list and then when the user clicks it, you can trigger a FragmentTransaction to place that Fragment into the right hand view. Then you can close the menu programmatically using SlidingMenu's showAbove() method.
If you were to launch Activities based upon the list selection, then you would not have the behavior where you swap the views that you're talking about.
Hopefully, I can implement this soon in the example for everybody to see.
Does this explain things a little better? I would definitely go and read up on Fragments in general.

@lynn8570
Copy link
Author

I am not familiar with Fragment, but you light me up. I am hoping your example could come out soon, and I am going to read up this project and figure out a solution. thanks a lot, ^_^

@drinu
Copy link

drinu commented Oct 22, 2012

Well done on the code, however I have this same issue.

How do you assign the fragments to the menu items and then later read them and switch to them?

Thanks in advance, and Great Work!

@lynn8570
Copy link
Author

Set the main acivite contentview as setContentView(R.layout.main); and there is a main container LinearLayout which we use to hold the fragment, and the we can replace the layout like the code show below

String className = (String) mMenuData.get(position).getClassName();//get the fragment class name
fragment = Fragment.instantiate(Home.this, className);//init the fragment
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
ft.replace(R.id.container, fragment);//replace the container with the new fragment
ft.commit();

I have just seen this email. sorry for replying you so lately

@lynn8570
Copy link
Author

Set the main acivite contentview as setContentView(R.layout.main); and
there is a main container LinearLayout which we use to hold the fragment,
and the we can replace the layout like the code show below

String className = (String) mMenuData.get(position).getClassName();//get
the fragment class name
fragment = Fragment.instantiate(Home.this, className);//init the fragment
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
ft.replace(R.id.container, fragment);//replace the container with the new
fragment
ft.commit();

I have just seen this email. sorry for replying you so lately

2012/10/22 drinu notifications@github.com

Well done on the code, however I have this same issue.

How do you assign the fragments to the menu items and then later read them
and switch to them?

Thanks in advance, and Great Work!


Reply to this email directly or view it on GitHubhttps://github.com//issues/5#issuecomment-9656501.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants