2010-07-11 46 views
2

如何創建拉出菜單作爲新的Activity如何創建拉出菜單作爲新的活動

是否可以有一個按鈕,您可以在Google內置的攝像機應用程序中拔出並啓動新的活動?

按鈕是否支持拔出?如果不是,那是什麼?

+4

什麼是「拔出菜單」? – CommonsWare 2010-07-11 13:47:26

+0

我不明白你的問題。 您可以在http://android.git.kernel.org/?p=platform/packages/apps/Camera.git;a=summary – Macarse 2010-07-11 13:51:34

+0

獲取Google在camrecorder應用程序中的內置版本。我的意思是,當您不是點擊而是將您的手指在GUI小部件上並進行拉動操作。 該操作會釋放一個菜單。 此行爲與Google攝像機應用中設置菜單發生的情況相同。 – Namratha 2010-07-12 03:38:29

回答

2

請參閱更新2獲得最佳解決方案!

我想我有同樣的問題。爲了更好地理解,我在一張照片中描述了它。我希望能跟大家能提供Namratha和我一些幫助......

alt text

(哦,我只注意到,該ImageUploader搞砸了我的圖畫文字,它會說:「我想建菜單下拉到我的應用程序。它應該就是這樣的例子。「)

UDPATE

感謝雅努什,誰告訴我,我應該尋找什麼。

出於某種原因,我總是在我的Eclipse佈局預覽出現此錯誤:

java.lang.IllegalArgumentException: The handle attribute is required and must refer to a valid child. 
    at android.widget.SlidingDrawer.<init>(SlidingDrawer.java:204) 
    at android.widget.SlidingDrawer.<init>(SlidingDrawer.java:181) 
    at sun.reflect.GeneratedConstructorAccessor204.newInstance(Unknown Source) 
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) 
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513) 
    at android.view.LayoutInflater.createView(LayoutInflater.java:499) 
    at android.view.BridgeInflater.onCreateView(BridgeInflater.java:77) 
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:562) 
    at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:122) 
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:617) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:407) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:296) 
    at com.android.layoutlib.bridge.Bridge.computeLayout(Bridge.java:377) 
    at com.android.ide.eclipse.adt.internal.editors.layout.gle1.GraphicalLayoutEditor.computeLayout(Unknown Source) 
    at com.android.ide.eclipse.adt.internal.editors.layout.gle1.GraphicalLayoutEditor.recomputeLayout(Unknown Source) 
    at com.android.ide.eclipse.adt.internal.editors.layout.gle1.GraphicalLayoutEditor.activated(Unknown Source) 
    at com.android.ide.eclipse.adt.internal.editors.layout.LayoutEditor.pageChange(Unknown Source) 
    at org.eclipse.ui.part.MultiPageEditorPart$2.widgetSelected(MultiPageEditorPart.java:290) 
    at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:234) 
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) 
    at org.eclipse.swt.widgets.Display.sendEvent(Display.java:3776) 
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1367) 
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1390) 
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1375) 
    at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1187) 
    at org.eclipse.swt.custom.CTabFolder.setSelection(CTabFolder.java:2743) 
    at org.eclipse.swt.custom.CTabFolder.destroyItem(CTabFolder.java:500) 
    at org.eclipse.swt.custom.CTabItem.dispose(CTabItem.java:126) 
    at org.eclipse.ui.part.MultiPageEditorPart.removePage(MultiPageEditorPart.java:1039) 
    at org.eclipse.ui.forms.editor.FormEditor.removePage(FormEditor.java:368) 
    at com.android.ide.eclipse.adt.internal.editors.layout.LayoutEditor.showEditorInput(Unknown Source) 
    at org.eclipse.ui.internal.WorkbenchPage.busyOpenEditorBatched(WorkbenchPage.java:2847) 
    at org.eclipse.ui.internal.WorkbenchPage.busyOpenEditor(WorkbenchPage.java:2768) 
    at org.eclipse.ui.internal.WorkbenchPage.access$11(WorkbenchPage.java:2760) 
    at org.eclipse.ui.internal.WorkbenchPage$10.run(WorkbenchPage.java:2711) 
    at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70) 
    at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2707) 
    at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2691) 
    at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2682) 
    at org.eclipse.ui.ide.IDE.openEditor(IDE.java:651) 
    at org.eclipse.ui.ide.IDE.openEditor(IDE.java:610) 
    at org.eclipse.jdt.internal.ui.javaeditor.EditorUtility.openInEditor(EditorUtility.java:365) 
    at org.eclipse.jdt.internal.ui.javaeditor.EditorUtility.openInEditor(EditorUtility.java:168) 
    at org.eclipse.jdt.ui.actions.OpenAction.run(OpenAction.java:229) 
    at org.eclipse.jdt.ui.actions.OpenAction.run(OpenAction.java:208) 
    at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun(SelectionDispatchAction.java:274) 
    at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run(SelectionDispatchAction.java:250) 
    at org.eclipse.jdt.internal.ui.navigator.OpenAndExpand.run(OpenAndExpand.java:49) 
    at org.eclipse.ui.actions.RetargetAction.run(RetargetAction.java:221) 
    at org.eclipse.ui.navigator.CommonNavigatorManager$3.open(CommonNavigatorManager.java:185) 
    at org.eclipse.ui.OpenAndLinkWithEditorHelper$InternalListener.open(OpenAndLinkWithEditorHelper.java:48) 
    at org.eclipse.jface.viewers.StructuredViewer$2.run(StructuredViewer.java:845) 
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) 
    at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:49) 
    at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:175) 
    at org.eclipse.jface.viewers.StructuredViewer.fireOpen(StructuredViewer.java:843) 
    at org.eclipse.jface.viewers.StructuredViewer.handleOpen(StructuredViewer.java:1131) 
    at org.eclipse.ui.navigator.CommonViewer.handleOpen(CommonViewer.java:462) 
    at org.eclipse.jface.viewers.StructuredViewer$6.handleOpen(StructuredViewer.java:1235) 
    at org.eclipse.jface.util.OpenStrategy.fireOpenEvent(OpenStrategy.java:264) 
    at org.eclipse.jface.util.OpenStrategy.access$2(OpenStrategy.java:258) 
    at org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrategy.java:298) 
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) 
    at org.eclipse.swt.widgets.Display.sendEvent(Display.java:3776) 
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1367) 
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1390) 
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1375) 
    at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1187) 
    at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3622) 
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3277) 
    at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2629) 
    at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2593) 
    at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2427) 
    at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:670) 
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) 
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:663) 
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) 
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:115) 
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196) 
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110) 
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79) 
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369) 
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
    at java.lang.reflect.Method.invoke(Method.java:597) 
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:619) 
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574) 
    at org.eclipse.equinox.launcher.Main.run(Main.java:1407) 

是這樣的佈局XML。我只是刪除了繪製資源指針...

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/LinearLayoutTesting" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical" 
    android:gravity="bottom"> 
    <SlidingDrawer 
    android:layout_width="wrap_content" 
    android:id="@+id/SlidingDrawer" 
    android:handle="@+id/slideHandleButton" 
    android:content="@+id/contentLayout" 
    android:padding="10dip" 
    android:layout_height="250dip"> 
    <Button 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:id="@+id/slideHandleButton"></Button> 
    <LinearLayout 
     android:layout_width="wrap_content" 
     android:id="@+id/contentLayout" 
     android:orientation="vertical" 
     android:gravity="center|top" 
     android:padding="10dip" 
     android:background="#C0C0C0" 
     android:layout_height="wrap_content"> 
     <Button 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Content"></Button> 
     <Button 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Content"></Button> 
     <Button 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Content"></Button> 
    </LinearLayout> 

    </SlidingDrawer> 

</LinearLayout> 

更新2

只注意到,有一個better solution我。因爲SlidingDrawer Widget只支持從底部滑動到頂部。我的第一個更新的錯誤仍然存​​在。

0

用於這種佈局的小部件是Sliding Drawer。您只需爲句柄定義一個佈局,併爲抽屜的內容定義一個佈局。現在,您可以聽取抽屜打開,滾動或關閉等事件。

+0

非常感謝!然而,不知何故,我總是得到這個錯誤:java.lang.IllegalArgumentException:句柄屬性是必需的,必須引用一個有效的孩子。 (請參閱我的更新瞭解詳情) – OneWorld 2010-11-01 10:29:46