I need to make an application with an activity
consisting of a GridView
and SlidingDrawer
.
I have done that, but now my problem is that I need to bring an activity for half of the screen whenever the SlidingDrawer
is dragged and the other half will be my previous activity
and when I drag back the SlidingDrawer
then the Activity
should be closed.
Is this possible to handle both the activities in the screen without any conflict and if possible how should I design those activities?
You cannot put an Activity
in a SlidingDrawer
. You can put a View
in a SlidingDrawer
.
Activity
of your SlidingDrawer
should extends ActivityGroup
. Get the view of the target activity, add view to SlidingDrawer
's content. Code like below:
private void initSlidingDrawerContent() { mTestContent.removeAllViews(); //View view = LayoutInflater.from(this).inflate(R.layout.act_test, null); View view = activityToView(this, new Intent(MainActivity.this, TestActivity.class)); mTestContent.addView(view); } private View activityToView(ActivityGroup parent, Intent intent) { LocalActivityManager mLocalActivityManager = parent.getLocalActivityManager(); final Window w = mLocalActivityManager.startActivity("TagName", intent); final View wd = w != null ? w.getDecorView() : null; if (wd != null) { wd.setVisibility(View.VISIBLE); wd.setFocusableInTouchMode(true); ((ViewGroup) wd) .setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS); } return wd; }
NOTE: NEVER startActivity(pkg, YourTargetActivity)
! So that the user never goes to YourTargetActivity as a stand-alone Activity
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.