Reputation: 9019
I want to show some menus in my action bar and need to have action bar in my application activity but I'm using Listactivity
public class MainActivity extends ListActivity{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
MyList.getInstance().getReminders();
list();
startService(new Intent(getApplicationContext(), locser.class));
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuItem menu1 = menu.add(0, 1, 0, "Start Service");
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if (id == 1) {
startService(new Intent(getApplicationContext(), locser.class));
}
return super.onOptionsItemSelected(item);
}
void list()
{
setListAdapter(new listadapter(this, R.layout.reminder_list_layout, MyList.getInstance().getReminders()));
reminders rem1=new reminders();
rem1.address="hello";
rem1.name="je";
MyList.getInstance().getReminders().add(rem1);
}
How to add action bar?
Upvotes: 0
Views: 246
Reputation: 5600
First make sure your Android minimum API-14 or later, add android:theme="@android:style/Theme.Holo.Light.DarkActionBar"
under your ListView_Activity in AndroidManifest.xml class put this:
<activity android:name=".Your_ListView_Activity"
android:theme="@android:style/Theme.Holo.Light.DarkActionBar"
android:label="ListView_Activity_Label">
Upvotes: 1