After I started my second Activity, there isn't the ActionBar. When I call GetSupportActivity, it returns null. Why? I have minSdkVersion 10 and targetSdkVersion 15.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.test.myapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="10"
android:targetSdkVersion="15"
/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.Sherlock.Light"
>
<activity
android:name=".MainActivity"
android:label="@string/title_activity_main"
android:windowSoftInputMode="stateHidden"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".ShowMusic2"
android:label="Search Results">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
</application>
</manifest>
This is the OnCreate of my second activity (ShowMusic2). It is a ListActivity.
public class ShowMusic2 extends SherlockListActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
showMusic = getIntent();
pkgName = getPackageName();
html = (String)showMusic.getStringExtra(pkgName + ".html");
new populateListView().execute(songs.toArray(new Song[songs.size()]));
adapter =new SongAdapter(this,R.layout.list_item1, songs.toArray(new Song[songs.size()]));
setListAdapter(adapter);
}
I havent played around with SherlockListActivity too much...but here's a shot in the dark....try moving
into your onStart method override instead of the onCreate
put below code in your style.xml file
This solution worked for me. And I hope this may help someone. :)
for the problem getSupportActionBar() always return NULL That is because you set theme NoActionBar in AndroidManifest.xml
Theme.Sherlock.Light.NoActionBar
If your application does not use action bar then no need use that method.