DrawerLayoutをActionBarSherlokで使用しようとしていますが、エラーが発生しています
06-30 15:37:18.874: E/AndroidRuntime(1305): java.lang.RuntimeException: アクティビティ ComponentInfo を開始できません{com.Priyesh/com.Priyesh.MainActivity}:android.view.InflateException: バイナリ XML ファイル行 # 1: クラス android.support.v4.widget.DrawerLayout の拡張エラー
ここに私のxmlファイルがあります
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<ListView
android:id="@+id/left_drawer"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#111"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp" />
</android.support.v4.widget.DrawerLayout>
と
package com.example;
import java.util.ArrayList;
import android.os.Bundle;
import android.support.v4.app.ActionBarDrawerToggle;
import android.support.v4.widget.DrawerLayout;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import com.actionbarsherlock.app.*;
import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuInflater;
public class MainActivity extends SherlockActivity {
DrawerLayout mydrawerlayout;
ListView drawerlist;
ArrayList<String> mplanetlist;
ActionBarDrawerToggle drawer_toggle;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mydrawerlayout = (DrawerLayout) findViewById(R.id.drawer_layout);
drawerlist = (ListView) findViewById(R.id.left_drawer);
drawerlist.setAdapter(newArrayAdapter<String(MainActivity.this,android.R.layout.sim ple_list_item_2,mplanetlist));
ActionBar actionbar = getSupportActionBar();
actionbar.show();
actionbar.setHomeButtonEnabled(true);
actionbar.setDisplayHomeAsUpEnabled(true);
drawer_toggle=newActionBarDrawerToggle(MainActivity.this,mydrawerlayout,R.drawable. ic_drawer, R.string.drawer_open , R.string.drawer_close )
{
public void onDrawerClosed(View view) {
getSupportActionBar().setTitle("drawer_open");
invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
}
public void onDrawerOpened(View drawerView) {
getSupportActionBar().setTitle("drawer_closse");
invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
}
};
mydrawerlayout.setDrawerListener(drawer_toggle);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater m = getSupportMenuInflater();
m.inflate(R.menu.main, menu);
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
return super.onPrepareOptionsMenu(menu);
}
}