谷歌地图V2在Android屏幕的上半部分和Android屏幕下半部分的列表视图

时间:2013-05-21 06:37:04

标签: java android google-maps-api-2

我正在开发一个Android项目,我需要在Android屏幕的上半部分显示Google Map v2,在同一个Android屏幕的下半部分,我需要显示ListView

以下是我到目前为止的代码,我将在启动应用程序后立即启动。我已正确设置AndroidManifest.xml的{​​{1}}文件。

Google Map V2 key

以下是我需要修改的public class SampleActivity extends Activity { @TargetApi(11) @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.sample); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { getActionBar().hide(); } findViewById(R.id.sample_button).setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { int width = (int) TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, 40, getResources() .getDisplayMetrics()); SlideoutActivity.prepare(SampleActivity.this, R.id.inner_content, width); startActivity(new Intent(SampleActivity.this, MenuActivity.class)); overridePendingTransition(0, 0); } }); } } ,以便我可以在Android屏幕的上半部分添加sample.xml file的内容,在下半部分,我将{{1} }}

Google Map v2

任何人都可以帮我吗?我完成了与设置Google Map API v2密钥相关的所有设置。我只需要插入代码,开始在Android屏幕的上半部分显示谷歌地图v2,并在Android屏幕的下半部分列出视图。

任何帮助将不胜感激。感谢

更新: -

此更新的XML文件是否可以在Android屏幕的上半部分安装Google Map v2,在Android屏幕的下半部分使用ListView?

ListView

2 个答案:

答案 0 :(得分:11)

这个布局应该在屏幕的上半部分显示一个地图,下半部分是一个ListView:

<?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:layout_weight="1.0"
    android:orientation="vertical" >

     <fragment
        xmlns:map="http://schemas.android.com/apk/res-auto"
        android:id="@+id/map"
        android:name="com.google.android.gms.maps.SupportMapFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>
</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_weight="1.0"
    android:orientation="vertical" >

    <ListView 
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/list">          
    </ListView>
</LinearLayout>

</LinearLayout>

答案 1 :(得分:0)

使用thisthis

希望能帮到你

相关问题