Need help to run my android app with extended ListActivity class -


i have 1 activity called main_activity.xml , 2 java classes called main.java & menu.java. in menu.java class extended listactivity class. when run myapp giving popup forceclose. plz help.

below code of menu.java:

public class menu extends listactivity{

string classes[]={"main","second","third","china"}; @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setlistadapter(new arrayadapter<string>(menu.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 selecteditem= classes[position];     try{         class myclass = class.forname("com.example.myapp."+selecteditem);         intent myintent=new  intent(menu.this, myclass);         startactivity(myintent);     }     catch(classnotfoundexception e)     {         e.printstacktrace();     } } 

}

main.java class code:

public class main extends activity {

@override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_main);     intent intent=new intent("com.example.myapp.menu");     startactivity(intent);  }   @override public boolean oncreateoptionsmenu(menu menu) {     // inflate menu; adds items action bar if present.     getmenuinflater().inflate(r.menu.main, menu);     return true; } 

}

mainfest file code:

<uses-sdk     android:minsdkversion="8"     android:targetsdkversion="17" />  <application     <activity         android:name="com.example.myapp.main"         android:label="@string/app_name" >         <intent-filter>             <action android:name="android.intent.action.main" />             <category android:name="android.intent.category.launcher" />         </intent-filter>     </activity>      <activity         android:name="com.example.myapp.menu"         android:label="@string/app_name" >         <intent-filter>             <action android:name="android.intent.action.menu" />             <category android:name="android.intent.category.default" />         </intent-filter>     </activity>   </application> 

error snap-sort:

enter image description here

no activity defined handle intent. because not initiating intent correctly in oncreate. try

intent intent = new intent(main.this,menu.class) main.this.startactivity(intent); 

edit: i'm bound ask have declared activity in manifest?


Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -