我正在尝试创建像滑动一样的 facebook 我已经尝试过这个库似乎对我不起作用..我需要像这个屏幕这样的东西..在滑动布局中,带有标题的列表视图,而在相同的活动内容中单击它应该会改变.实际上使用上面的库我试过这样:
public class MainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTitle(R.string.attach);
// set the content view
setContentView(R.layout.content);
// configure the SlidingMenu
SlidingMenu menu = new SlidingMenu(this);
menu.setMode(SlidingMenu.LEFT);
menu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
menu.setShadowWidthRes(R.dimen.shadow_width);
menu.setShadowDrawable(R.drawable.shadow);
menu.setBehindOffsetRes(R.dimen.slidingmenu_offset);
menu.setFadeDegree(0.35f);
menu.attachToActivity(this, SlidingMenu.SLIDING_CONTENT);
menu.setMenu(R.layout.menu);
}
}
这根本不起作用!错误:
07-20 10:17:19.776: E/AndroidRuntime(1134): FATAL EXCEPTION: main
07-20 10:17:19.776: E/AndroidRuntime(1134): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.app.example/com.app.example.MainActivity}: java.lang.IllegalStateException: Both setBehindContentView must be called in onCreate in addition to setContentView.
07-20 10:17:19.776: E/AndroidRuntime(1134): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
07-20 10:17:19.776: E/AndroidRuntime(1134): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
07-20 10:17:19.776: E/AndroidRuntime(1134): at android.app.ActivityThread.access$600(ActivityThread.java:141)
07-20 10:17:19.776: E/AndroidRuntime(1134): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
07-20 10:17:19.776: E/AndroidRuntime(1134): at android.os.Handler.dispatchMessage(Handler.java:99)
07-20 10:17:19.776: E/AndroidRuntime(1134): at android.os.Looper.loop(Looper.java:137)
07-20 10:17:19.776: E/AndroidRuntime(1134): at android.app.ActivityThread.main(ActivityThread.java:5041)
07-20 10:17:19.776: E/AndroidRuntime(1134): at java.lang.reflect.Method.invokeNative(Native Method)
07-20 10:17:19.776: E/AndroidRuntime(1134): at java.lang.reflect.Method.invoke(Method.java:511)
07-20 10:17:19.776: E/AndroidRuntime(1134): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
07-20 10:17:19.776: E/AndroidRuntime(1134): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
07-20 10:17:19.776: E/AndroidRuntime(1134): at dalvik.system.NativeStart.main(Native Method)
07-20 10:17:19.776: E/AndroidRuntime(1134): Caused by: java.lang.IllegalStateException: Both setBehindContentView must be called in onCreate in addition to setContentView.
07-20 10:17:19.776: E/AndroidRuntime(1134): at com.jeremyfeinstein.slidingmenu.lib.app.SlidingActivityHelper.onPostCreate(SlidingActivityHelper.java:55)
07-20 10:17:19.776: E/AndroidRuntime(1134): at com.jeremyfeinstein.slidingmenu.lib.app.SlidingActivity.onPostCreate(SlidingActivity.java:36)
07-20 10:17:19.776: E/AndroidRuntime(1134): at android.app.Instrumentation.callActivityOnPostCreate(Instrumentation.java:1143)
07-20 10:17:19.776: E/AndroidRuntime(1134): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2163)
07-20 10:17:19.776: E/AndroidRuntime(1134): ... 11 more
菜单xml:
<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:name="com.app.example.SampleListFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</fragment>
清单文件:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.app.example"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="7"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.Myactionbar"
>
<activity
android:name="com.app.example.MainActivity"
android:configChanges="orientation|screenSize|screenLayout"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
有人可以帮我吗@thanks