I reviewed this question, however, this did not help solve my problem:
I use ActionBarSherlock (version 4.4) in my application for compatibility in older versions. My application works fine on 4.1.2, but it crashes on 2.3.3. The application runs to the point mDrawerLayout.closeDrawer(mDrawerList); , after which it will work after that. I canβt understand what causes it to crash in older versions. I feel this is because he is trying to use something that does not exist in this version, but I canβt determine exactly what he is using. Does anyone see any code that seems wrong?
Error in logcat: Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x2/d=0x10102fd a=-1}
Logcat Error
08-15 21:01:04.967: E/AndroidRuntime(789): FATAL EXCEPTION: main 08-15 21:01:04.967: E/AndroidRuntime(789): android.view.InflateException: Binary XML file line
styles.xml from the values ββfolder:
<resources> <style name="AppBaseTheme" parent="Theme.Sherlock.Light.DarkActionBar"> </style> <style name="AppTheme" parent="AppBaseTheme"> </style> </resources>
Java file
protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub setTheme(R.style.Theme_Sherlock); super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Log.d(TAG,"Set Content View"); mTitle = (String) getTitle(); ChemTitles = getResources().getStringArray(R.array.chemistrycalcstrings); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (ListView) findViewById(R.id.left_drawer); mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); mDrawerList.setAdapter(new ArrayAdapter<String>(this, R.layout.drawer_list_item, ChemTitles)); mDrawerList.setOnItemClickListener(new DrawerItemClickListener()); getSupportActionBar().setDisplayHomeAsUpEnabled(true); Log.d(TAG,"Set Display Home"); getSupportActionBar().setHomeButtonEnabled(true); Log.d(TAG,"Set Home Button"); Log.d(TAG,"Setting ActbarDrawerToggle"); mDrawerToggle = new ActionBarDrawerToggle( this, mDrawerLayout, R.drawable.ic_drawer, R.string.drawer_open, R.string.drawer_close ) { public void onDrawerClosed(View view){ getSupportActionBar().setTitle(mTitle); getSherlock().dispatchInvalidateOptionsMenu(); Log.d(TAG,"Drawer CLosing"); } public void onDrawerOpened(View drawerView){ getSupportActionBar().setTitle(mDrawerTitle); getSherlock().dispatchInvalidateOptionsMenu(); Log.d(TAG,"Drawer Opening"); } }; Log.d(TAG,"Set ActbarDrawerToggle"); mDrawerLayout.setDrawerListener(mDrawerToggle); Log.d(TAG,"Set ActbarDrawerToggle Listener"); if (savedInstanceState == null){ selectItem(0); } } private void selectItem(int position){ SherlockFragment frag = new TestFrament(); Bundle args = new Bundle(); args.putInt(TestFrament.ITEM_SEL, position); frag.setArguments(args); getSupportFragmentManager().beginTransaction().replace(R.id.content_frame, frag).commit(); mDrawerList.setItemChecked(position, true); setTitle(ChemTitles[position]); mDrawerLayout.closeDrawer(mDrawerList); }
EDIT / UPDATE
I looked through and commented on all the parts that included listview mDrawerList , and the application started directly with the action bar and there was no list in the box.
Activity_main.xml layout
<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"> <LinearLayout android:id="@+id/content_frame" android:orientation="horizontal" 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:choiceMode="singleChoice" android:divider="@android:color/transparent" android:dividerHeight="0dp" android:background="#111"/> </android.support.v4.widget.DrawerLayout>
drawer_list_item.xml
<TextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/text1" android:layout_width="match_parent" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceListItemSmall" android:gravity="center_vertical" android:paddingLeft="16dp" android:paddingRight="16dp" android:textColor="#fff" android:background="?android:attr/activatedBackgroundIndicator" android:minHeight="?android:attr/listPreferredItemHeightSmall"/>
test_fragment_layout.xml
<TextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/fragTextSherlock" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#FFFFFF" android:gravity="center" android:padding="32dp" />
TestFragment.java
public class TestFrament extends SherlockFragment { public static final String ITEM_SEL = "item_selected"; private TextView fragtv; public TestFrament() {