开发者

An activity contain both map and tab in android

Actually my map layout code with out tab is below one

<?xml version="1.0" encoding="utf-8"?> 
<FrameLayout 
    android:id="@+id/FrameLayoutPeople" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    xmlns:android="http://schemas.android.com/apk/res/android">
    <com.google.android.maps.MapView 
            android:id="@+id/mapView" 
            android:layout_width="fill_parent" 
            android:enabled="true" 
            android:clickable="true" 
            android:apiKey="@string/apikey" 
            android:layout_height="wrap_content" 
            />

<RelativeLayout     
android:orientation="vertical"
android:layout_width="fill_parent"
android:id="@+id/linerlayouttransparent"
android:layout_height="wrap_content">

<com.fitzengineering.teslaworldnet.presentationlayer.TransparentPanel
android:id="@+id/transparent_panel" 
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingTop="5px"
android:paddingLeft="5px"
android:paddingBottom="10px"
android:paddingRight="5px" >

<LinearLayout  xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/LinearLayout5" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent"
android:orientation="vertical"> 
<TextView 
android:id="@+id/TextViewEmpty"
android:layout_width="wrap_content"
 android:layout_height="5dip"
 /> 

<TextView android:id="@+id/TextViewName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
 android:text="People" 
 android:textStyle="bold" 
 android:layout_gravity="center_vertical|center_horizontal"
 android:textSize="20dip"
 android:textColor="@android:color/white"/>
<TextView 
android:id="@+id/TextViewEmpty"
android:layout_width="wrap_content"
android:layout_height="5dip"/>

<LinearLayout android:id="@+id/LinearLayout02" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:orientation="horizontal" android:clickable="false">
<TextView
android:id="@+id/TextViewEmpty" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:width="30dp"/> 
<TextView 
android:id="@+id/TextViewName"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
 android:text="Name" 
 android:textStyle="bold" 
 android:width="100sp"
 android:textColor="@android:color/white"/> 

<TextView 
android:id="@+id/TextViewLatitude" 
android:layout_width="fill_parent"
android:layout_height="wrap_content" 
 android:text="Address" 
android:textStyle="bold"
android:width="100dip"
 android:textColor="@android:color/white"/>
</LinearLayout>

<ScrollView
android:id="@+id/ScrollView01"  
android:layout_width="fill_parent"
android:layout_height="150sp" 
android:orientation="vertical" >
<LinearLayout 
android:id="@+id/LinearLayoutPeople" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:orientation="vertical" 
android:layout_margin="10dip">
</LinearLayout>
</ScrollView>

<LinearLayout
    android:id="@+id/LinearLayoutButtons"
    android:layout_width="wrap_content" 
    android:layout_height="fill_parent"
    android:orientation="horizontal"
    android:gravity="bottom">
<TextView 
    android:id="@+id/TextViewEmpty" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:width="10dip"/>
<ImageView
     android:id="@+id/ImageViewBackinPeople" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:clickable="true" 
    android:focusable="true"        
    android:src="@drawable/back_normal_icon"> 
    </ImageView>
    <TextView 
    android:id="@+id/TextViewEmpty" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
开发者_运维技巧    android:width="30dip"/>
<ImageView
    android:id="@+id/ImageViewAddRemoveinPeople" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:clickable="true" 
    android:focusable="true"        
    android:src="@drawable/addremove_normal_icon"> 
    </ImageView>
<TextView 
    android:id="@+id/TextViewEmpty" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:width="40dip"/>

 <ImageView
     android:id="@+id/ImageViewShowDetailsinPeoples" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:clickable="true" 
    android:focusable="true" 
    android:src="@drawable/showdetails_normal_icon" 
    > 
    </ImageView>
     </LinearLayout> 
  </LinearLayout>
  </com.fitzengineering.teslaworldnet.presentationlayer.TransparentPanel>
  </RelativeLayout>
  </FrameLayout> 

in that when i add tab code at top of this code like

<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost" 
android:layout_width="fill_parent"
android:layout_height="fill_parent">

<TabWidget android:id="@android:id/tabs" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" />
</TabHost >

it shows error. and other thing in java file i perform some operations on map when the java is extend with TabActivity those are not working. so,Give me some suggestions for this .Thanks in advance


extend your class with Tabactivity. setContent with Mapview. simple.

Edit:

well.

this is the sample code for activity looks.

public class BS_Main extends TabActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
          TabHost tabHost = getTabHost();
    tabHost.addTab(tabHost.newTabSpec("tab1").setContent(R.id.mapview).setIndicator("mapview_name",getResources().getDrawable(R.drawable.map_icon)));
    tabHost.addTab(tabHost.newTabSpec("tab2").setContent(R.id.anotherview).setIndicator("tab2_name",getResources().getDrawable(R.drawable.anotherview_icon)));
  }
}

the layout of tab activity looks.

<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost" 
android:layout_width="fill_parent"
android:layout_height="fill_parent">

    <TabWidget android:id="@android:id/tabs" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" />

    <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"            
     android:orientation="vertical" 
     android:id="@android:id/tabcontent"
     android:layout_width="fill_parent"
     android:layout_height="fill_parent">

        <mapview tag here with ur map Api key>
        <anotherview tag>

    </FrameLayout>
</TabHost>

thats it.refer this link too.


TabActivity was deprecated in API level 13.try ActionBar with tabs navigation mode,in each tab you can use fragments include MapFragment.see the TabActivity documents http://developer.android.com/reference/android/app/TabActivity.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜