已经看过了:NoClassDefFoundError Android 与 ActionBarActivity and ActionBarActivity 在电话上捕获错误
我正在尝试使用紧凑型操作栏在我的项目中。我已经链接了android-支持-v7项目及其在我的项目中的 jar 遵循并检查来自许多来源的步骤,但我仍然无法处理该问题。
当我构建项目时,没有错误,但运行时出现异常。不知道为什么没有检测到班级。请告诉我出了什么问题。谢谢。
Code:
import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBarActivity;
import android.widget.ArrayAdapter;
public class mainMenu extends ActionBarActivity implements ActionBar.OnNavigationListener {
ActionBar actionbar;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.menutab);
actionbar = getSupportActionBar();
actionbar.setTitle("Menu");
actionbar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
ArrayAdapter<CharSequence> mSpinnerAdapter = ArrayAdapter.createFromResource(this,R.array.menu_items, R.id.simpleText);
actionbar.setListNavigationCallbacks(mSpinnerAdapter, this);
}
@Override
public boolean onNavigationItemSelected(int arg0, long arg1)//item pos, itemid
{
switch (arg0) {
case 0:
System.out.println("selected: " + arg0);
break;
case 1:
System.out.println("selected: " + arg0);
break;
case 2:
System.out.println("selected: " + arg0);
break;
case 3:
System.out.println("selected: " + arg0);
break;
default:
break;
}
return true;
}
}
------------项目结构和构建路径-----------------
Logcat
尝试这个:
如果仍然不能解决您的问题,请重新启动 eclipse。
然后清理并重建项目
如果问题仍然存在,请从计算机中删除支持库并重新下载,然后按照上述步骤操作。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)