android - Error in MainActivity when implementing TabActivity -
i want page text on top(edittext) image (in fragmentlayout) , 2 tabs below image. output not showing tab in output have written code implement tabs. code notshowing error , in output mam not getting tab in output
i not getting correct output , not showing error tried without extending tabactivity (only extens activity) still output same image loaded above code of activity_main.xml
<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context=".mainactivity" > <textview android:id="@+id/tbol" android:layout_width="250dp" android:layout_height="30dp" android:text="@string/heading" android:textappearance="?android:attr/textappearancemedium" android:textcolor="#f00" android:textsize="25sp" /> <framelayout android:layout_width="match_parent" android:layout_height="160dp" android:background="@drawable/leaf" > </framelayout> <tabhost android:id="@android:id/tabhost" android:layout_width="match_parent" android:layout_height="match_parent" > <linearlayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <tabwidget android:id="@android:id/tabs" android:layout_width="match_parent" android:layout_height="wrap_content" > </tabwidget> <framelayout android:id="@android:id/tabcontent" android:layout_width="match_parent" android:layout_height="match_parent" > </framelayout> </linearlayout> </tabhost> </linearlayout>
code of mainactivity.java is
package com.example.tabhost; import android.os.bundle; import android.app.tabactivity; import android.content.intent; import android.widget.tabhost; import android.widget.tabhost.tabspec; @suppresswarnings("deprecation") public class mainactivity extends tabactivity { tabhost th; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); th=gettabhost(); //for desc tab tabspec descspec=th.newtabspec("description"); descspec.setindicator("description", null); intent firstintent=new intent(this, decsriptiontab.class); descspec.setcontent(firstintent); //for information tab tabspec infospec=th.newtabspec("information"); infospec.setindicator("information", null); intent secondintent=new intent(this, info_tab.class); descspec.setcontent(secondintent); } }
this code of 2 .xml files
desc_layout.xml
<?xml version="1.0" encoding="utf-8"?> <linearlayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" xmlns:android="http://schemas.android.com/apk/res/android"> <textview android:text="this desc tab" android:padding="15dp" android:textsize="18sp" android:layout_width="fill_parent" android:layout_height="wrap_content"/> </linearlayout>
info_layout
<?xml version="1.0" encoding="utf-8"?> <linearlayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" xmlns:android="http://schemas.android.com/apk/res/android"> <textview android:text="this info tab" android:padding="15dp" android:textsize="18sp" android:layout_width="fill_parent" android:layout_height="wrap_content"/> </linearlayout>
this code of corresponding java files
decsriptiontab.java
package com.example.tabhost; import android.app.activity; import android.os.bundle; public class decsriptiontab extends activity { @override protected void oncreate(bundle savedinstancestate) { // todo auto-generated method stub super.oncreate(savedinstancestate); setcontentview(r.layout.desc_layout); } }
info_tab.java
package com.example.tabhost; import android.app.activity; import android.os.bundle; public class info_tab extends activity { @override protected void oncreate(bundle savedinstancestate) { // todo auto-generated method stub super.oncreate(savedinstancestate); setcontentview(r.layout.info_layout); } }
Comments
Post a Comment