java.lang.ClassNotFoundException:com.ku.aajakobazzar.MainActivity error

时间:2013-12-27 14:52:40

标签: java android

在方法onlistitemclick中...尝试阻止无效....并且正在捕获异常导致

  

java.lang.ClassNotFoundException:com.ku.aajakobazzar.MainActivity error

我的代码是

package com.ku.aajakobazzar;


public class Mainmenu extends ListActivity {

String classes[] = { "ViewPrice" , "UpdatePrice" , "Preferences" , "Exit" };

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setListAdapter(new ArrayAdapter<String>(Mainmenu.this, android.R.layout.simple_list_item_1, classes));
}

@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
    // TODO Auto-generated method stub
    super.onListItemClick(l, v, position, id);
    String choose =classes[position];
    try{
        Class ourclass = Class.forName("com.ku.aajakobazzar." + choose);
        Intent ourinIntent = new Intent(Mainmenu.this, ourclass);
        startActivity(ourinIntent);

    }catch(ClassNotFoundException e){
        e.printStackTrace();
    }
}

1 个答案:

答案 0 :(得分:0)

简短回答:类com.ku.aajakobazzar.MainActivity因此不在您的项目依赖项中。