スライド メニューのコンテンツの背後に設定アクティビティを配置しようとしています。
ここに私のmain_menu.xmlがあります
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:background="#202222"
tools:context=".MainActivity" >
<PreferenceScreen
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<PreferenceCategory android:title="@string/general" >
<Preference android:title="@string/news" />
<Preference android:title="@string/sport" />
<Preference android:title="@string/business" />
<Preference android:title="@string/economy" />
</PreferenceCategory>
<PreferenceCategory android:title="@string/news" >
<Preference android:title="@string/international" />
<Preference android:title="@string/national"/>
<Preference android:title="@string/local" />
</PreferenceCategory>
</PreferenceScreen>
これは私が MainActivity.java で行うことです
public class MainActivity extends SlidingActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setBehindContentView(R.layout.main_menu);
getSlidingMenu().setBehindOffset(120);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
アプリケーションを実行するとクラッシュし、「インフレに失敗しました。android.view.InflateException: Binary XML file line #12: Error inflating class PreferenceScreen」と表示されます
この例外もあります:com.android.layoutlib.bridge.MockViewはmain_menu.xmlのandroid.view.ViewGroupにキャストできません
私はそのようなことをしたい:画像の例