我在我的项目中添加了google play service v 2以及在android 2.3上运行的代码,但在android 4地图上没有出现在活动上 我是android的新手,这是我的代码
public class MapActivity extends ActionBarActivity
{
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_map);
generateUI();
MapFragment map = new MapFragment();
FragmentManager manager = getSupportFragmentManager();
FragmentTransaction transaction = manager.beginTransaction();
transaction.add(R.id.first_fragment, map);
transaction.commit();
}
}
布局:
<RelativeLayout 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"
tools:context="com.realtyna.android.activity.MapActivity" >
<FrameLayout
android:id="@+id/first_fragment"
android:layout_width="match_parent"
android:visibility="invisible"
android:layout_height="match_parent" />
<FrameLayout
android:id="@+id/second_fragment"
android:layout_width="match_parent"
android:visibility="invisible"
android:layout_height="match_parent" />
</RelativeLayout>
答案 0 :(得分:2)
难怪你无法看到它,因为你在布局中明确地设置了它:
android:visibility="invisible"