Hi when i am trying to add tabs i am getting nullpointer exception.I am creating one activity MyLanguageActivity this extends Activity and i am creating one more activity MyTabActivity this extends TabActivity.Inside of MyLangugeActivity i am selecting language and i am tapping on done button i am adding tabs one more time like this :
public void setTabs(){
Intent intent, intent1, intent2, intent3;
TabHost tabHost = MyTabActivity.tabHost;
System.out.println(tabHost);
TextView tv;
intent = new Intent(
"com.activitygroups.RequestTabActivtyGroup");
intent1 = new Intent(
"com.activitygroups.OffersTabActivityGroup");
intent.putExtra("content", "requests");
intent1.putExtra("content", "offers");
System.out.println("request string : "
+ getResources().getString(R.string.requests));
System.out.println("drowable id : "
+ getResources().getDrawable(R.drawable.request_tab_selector));
tabHost.addTab(tabHost
.newTabSpec("request_tab")
.setIndicator(
LanguageUtils.getLanguage(MyLanguageActivity.this,
getResources().getString(R.string.requests)),
getResources().getDrawable(
R.drawable.request_tab_selector))
.setContent(
new Intent(intent)
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)));
}
inside og done button onclick i am calling this method.When i tap on done i am getting nullpointer exception.. My logcat here :
02-10 12:32:37.112: E/AndroidRuntime(5560): FATAL EXCEPTION: main
02-10 12:32:37.112: E/AndroidRuntime(5560): java.lang.NullPointerException
02-10 12:32:37.112: E/AndroidRuntime(5560): at android.widget.TabWidget.setCurrentTab(TabWidget.java:339)
02-10 12:32:37.112: E/AndroidRuntime(5560): at android.widget.TabWidget.focusCurrentTab(TabWidget.java:363)
02-10 12:32:37.112: E/AndroidRuntime(5560): at android.widget.TabHost.setCurrentTab(TabHost.java:320)
02-10 12:32:37.112: E/AndroidRuntime(5560): at android.widget.TabHost.addTab(TabHost.java:213)
02-10 12:32:37.112: E/AndroidRuntime(5560): at com.melhoroferta.LanguageSettingActivity.setUpTabs(MyLanguageActivity.java:204)
02-10 12:32:37.112: E/AndroidRuntime(5560): at com.melhoroferta.LanguageSettingActivity.onClick(MyLanguageActivity.java:142)
02-10 12:32:37.112: E/AndroidRuntime(5560): at android.view.View.performClick(View.java:2408)
02-10 12:32:37.112: E/AndroidRuntime(5560): at android.view.View$PerformClick.run(View.java:8818)
02-10 12:32:37.112: E/AndroidRuntime(5560): at android.os.Handler.handleCallback(Handler.java:587)
02-10 12:32:37.112: E/AndroidRuntime(5560): at android.os.Handler.dispatchMessage(Handler.java:92)
02-10 12:32:37.112: E/AndroidRuntime(5560): at android.os.Looper.loop(Looper.java:123)
02-10 12:32:37.112: E/AndroidRuntime(5560): at android.app.ActivityThread.main(ActivityThread.java:4627)
02-10 12:32:37.112: E/AndroidRuntime(5560): at java.lang.reflect.Method.invokeNative(Native Method)
02-10 12:32:37.112: E/AndroidRuntime(5560): at java.lang.reflect.Method.invoke(Method.java:521)
02-10 12:32:37.112: E/AndroidRuntime(5560): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:871)
02-10 12:32:37.112: E/AndroidRuntime(5560): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:629)
02-10 12:32:37.112: E/AndroidRuntime(5560): at dalvik.system.NativeStart.main(Native Method)
Sorry guys i am forgot to remove those intent 2 and intent 3 actually this intents are i am not using..