I'm trying to set up an application that allows users to find local businesses and events. I had a working map, but I'm having trouble getting it to integrate into a tabbed action bar. Unfortunately it says "Unfortunately, [app] has stopped." any help would be greatly appreciated.
ActionBarMain.java
@SuppressLint("NewApi")
public class ActionBarMain extends Activity implements TabListener {
RelativeLayout rl;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_action_bar_main);
try {
rl = (RelativeLayout) findViewById(R.id.mainLayout);
fragMentTra = getFragmentManager().beginTransaction();
ActionBar bar = getActionBar();
bar.addTab(bar.newTab().setText("Map").setTabListener(this));
bar.addTab(bar.newTab().setText("Businesses").setTabListener(this));
bar.addTab(bar.newTab().setText("Events").setTabListener(this));
bar.addTab(bar.newTab().setText("Facebook").setTabListener(this));
bar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM
| ActionBar.DISPLAY_USE_LOGO);
bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
bar.setDisplayShowHomeEnabled(true);
bar.setDisplayShowTitleEnabled(false);
bar.show();
} catch (Exception e) {
e.getMessage();
}
/**
* Hiding Action Bar
*/
}
Fragment fram1;
FragmentTransaction fragMentTra = null;
FragMent2 fram2;
FragMent3 fram3;
FragMent4 fram4;
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_action_bar_main, menu);
return true;
}
@Override
public void onTabReselected(Tab tab, FragmentTransaction ft) {
}
@Override
public void onTabSelected(Tab tab, FragmentTransaction ft) {
if (tab.getText().equals("Map")) {
try {
rl.removeAllViews();
} catch (Exception e) {
}
fram1 = new Fragment();
fragMentTra.addToBackStack(null);
fragMentTra = getFragmentManager().beginTransaction();
fragMentTra.add(rl.getId(), fram1);
fragMentTra.commit();
} else if (tab.getText().equals("Businesses")) {
try {
rl.removeAllViews();
} catch (Exception e) {
}
fram2 = new FragMent2();
fragMentTra.addToBackStack(null);
fragMentTra = getFragmentManager().beginTransaction();
fragMentTra.add(rl.getId(), fram2);
fragMentTra.commit();
} else if (tab.getText().equals("Events")) {
try {
rl.removeAllViews();
} catch (Exception e) {
}
fram3 = new FragMent3();
fragMentTra.addToBackStack(null);
fragMentTra = getFragmentManager().beginTransaction();
fragMentTra.add(rl.getId(), fram3);
fragMentTra.commit();
} else if (tab.getText().equals("Facebook")) {
try {
rl.removeAllViews();
} catch (Exception e) {
}
fram2 = new FragMent2();
fragMentTra.addToBackStack(null);
fragMentTra = getFragmentManager().beginTransaction();
fragMentTra.add(rl.getId(), fram2);
fragMentTra.commit();
}
}
@Override
public void onTabUnselected(Tab tab, FragmentTransaction ft) {
}
}
FragMent1.java:
public class FragMent1 extends FragmentActivity{
SupportMapFragment mMap;
GoogleMap googleMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_action_bar_main);
mMap = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.mainGrid);
googleMap = mMap.getMap();
}
}
AndroidManifest.xml:
package="com.ahmad.actionBar"
android:versionCode="1"
android:versionName="1.0" >
android:name="com.ahmad.actionbar.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
android:minSdkVersion="11"
android:targetSdkVersion="17" />
android:glEsVersion="0x00020000"
android:required="true"/>
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:allowBackup="True">
android:name="com.google.android.maps.v2.API_KEY"
android:value="super_secret_key"/>
android:name="com.ahmad.actionbar.MainActivity"
android:label="@string/app_name" >
android:name=".ActionBarMain"
android:label="@string/title_activity_action_bar_main"
android:uiOptions="splitActionBarWhenNarrow" >
EDIT:
fixed a few errors of trying to integrate two apps together and added new logcat.
logcat:
04-24 21:34:33.242: D/AndroidRuntime(11335): Shutting down VM
04-24 21:34:33.242: W/dalvikvm(11335): threadid=1: thread exiting with uncaught exception (group=0x40e26930)
04-24 21:34:33.252: E/AndroidRuntime(11335): FATAL EXCEPTION: main
04-24 21:34:33.252: E/AndroidRuntime(11335): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.ahmad.actionBar/com.ahmad.actionbar.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.ahmad.actionbar.MainActivity" on path: /data/app/com.ahmad.actionBar-2.apk
04-24 21:34:33.252: E/AndroidRuntime(11335): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2106)
04-24 21:34:33.252: E/AndroidRuntime(11335): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
04-24 21:34:33.252: E/AndroidRuntime(11335): at android.app.ActivityThread.access$600(ActivityThread.java:141)
04-24 21:34:33.252: E/AndroidRuntime(11335): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
04-24 21:34:33.252: E/AndroidRuntime(11335): at android.os.Handler.dispatchMessage(Handler.java:99)
04-24 21:34:33.252: E/AndroidRuntime(11335): at android.os.Looper.loop(Looper.java:137)
04-24 21:34:33.252: E/AndroidRuntime(11335): at android.app.ActivityThread.main(ActivityThread.java:5041)
04-24 21:34:33.252: E/AndroidRuntime(11335): at java.lang.reflect.Method.invokeNative(Native Method)
04-24 21:34:33.252: E/AndroidRuntime(11335): at java.lang.reflect.Method.invoke(Method.java:511)
04-24 21:34:33.252: E/AndroidRuntime(11335): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
04-24 21:34:33.252: E/AndroidRuntime(11335): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
04-24 21:34:33.252: E/AndroidRuntime(11335): at dalvik.system.NativeStart.main(Native Method)
04-24 21:34:33.252: E/AndroidRuntime(11335): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.ahmad.actionbar.MainActivity" on path: /data/app/com.ahmad.actionBar-2.apk
04-24 21:34:33.252: E/AndroidRuntime(11335): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)
04-24 21:34:33.252: E/AndroidRuntime(11335): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
04-24 21:34:33.252: E/AndroidRuntime(11335): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
04-24 21:34:33.252: E/AndroidRuntime(11335): at android.app.Instrumentation.newActivity(Instrumentation.java:1054)
04-24 21:34:33.252: E/AndroidRuntime(11335): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097)
04-24 21:34:33.252: E/AndroidRuntime(11335): ... 11 more
.
stackoverflow.comm
No comments:
Post a Comment