私はアンドロイドでプログラミングをマップする初心者です。以下のレイアウトに従って、マップフラグメントの上にボタンの行を追加しようとしています:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Tilt"
android:onClick="tilt" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Move"
android:onClick="move"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="@+id/mymap">
</LinearLayout>
</LinearLayout>
public class MainActivity extends Activity
{
GoogleMap gm;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.finallay);
MapFragment mp=new MapFragment();
getFragmentManager().beginTransaction().add(R.id.mymap,mp).commit();
}
}
ただし、結果のビューにはマップが表示されず、ボタンのみが表示されます。ここで間違いを犯しています。ボタンを追加しなくても、フラグメントタグは正常に機能しています。ありがとう