Android : how perform the click of Actionbar Item In sherlock Fragment in android

on Tuesday, October 14, 2014


i want to perform click of actionbar item in sherlock fragment my item is showing on fragment class on action bar ....but when i click on item .. doing nothing mean not showing Toast message ....


please can u tell me where i m soing wrong ?


here is my Code of sherlock Fragment



@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
// TODO Auto-generated method stub
inflater.inflate(R.menu.profile_menu_items, menu);
super.onCreateOptionsMenu(menu, inflater);

}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// TODO Auto-generated method stub
switch (item.getItemId()) {
case R.id.Online:
// do s.th.
Toast.makeText(getActivity(), "online", Toast.LENGTH_SHORT).show();
return true;
default:
return super.onOptionsItemSelected(item);
}



@Override
public void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub

super.onCreate(savedInstanceState);
setHasOptionsMenu(true);

}}


here Is MEnu File



<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >

<item android:id="@+id/Online"
android:showAsAction="always"
android:title="Online"/>
</menu>


thanku In Advance


0 comments:

Post a Comment