在我的应用程序类 ProjectFragActivtiy 遇到异常,如
java.lang.ClassCastException: com.actionbarsherlock.internal.view.menu.MenuBuilder
at com.oj.bs.ProjectFragActivity.onCreateOptionsMenu
(ProjectFragActivity.java:49).
在应用程序菜单按钮用于注销操作但遇到异常。是否有另一种方法来实现 actionbarsherlock 中的菜单。有人对此有解决方案吗?提前致谢。
以下是 ProjectFragActivtiy 类
package com.oj.bs;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;
import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.app.ActionBar.Tab;
import com.actionbarsherlock.app.SherlockFragmentActivity;
import com.actionbarsherlock.view.Menu;
public class ProjectFragActivity extends SherlockFragmentActivity {
SessionManager sessionMngr ;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
sessionMngr = new SessionManager(getApplicationContext());
Toast.makeText(getApplicationContext(), "User Login Status: " + sessionMngr .isLoggedIn(),
Toast.LENGTH_LONG).show();
sessionMngr.checkLogin();
ActionBar actionBar = getSupportActionBar();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
actionBar.setDisplayShowTitleEnabled(true);
Tab tab = actionBar.newTab().
setText("Residential").
setTabListener(new ResidentialFragActivity()).
setIcon(R.drawable.residential);
actionBar.addTab(tab);
tab = actionBar.newTab().
setText("Commercial").
setTabListener(new CommercialFragActivity()).
setIcon(R.drawable.commercial);
actionBar.addTab(tab);
}
public void Logout(View v) {
sessionMngr.logoutUser();
}
@Override
public boolean onCreateOptionsMenu(Menu m) {
getMenuInflater().inflate(R.menu.menu_logout, (android.view.Menu) m);
return true;
}
}