活动同时包含地图和标签中的Android [英] An activity contain both map and tab in android
问题描述
其实我的地图布局code与出选项卡下面的一个
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>
在那个时候我在这个code上添加标签code像
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 >
它显示错误。
在的Java文件其他的事情,我在地图上执行某些操作当Java是TabActivity那些没有工作的延伸。
所以,给我这个.Thanks一些建议提前
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
推荐答案
与Tabactivity扩展您的类。 setContent与图形页面。简单。
extend your class with Tabactivity. setContent with Mapview. simple.
编辑:
以及
这是样品code的活动的样子。
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>
这就是it.refer此<一个href=\"http://vkroz.word$p$pss.com/2009/07/03/programming-android-%E2%80%93-map-view-within-tab-view/\"相对=nofollow>链接了。
这篇关于活动同时包含地图和标签中的Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!