在Android的触摸事件的MapView [英] Touch event in MapView in android

查看:118
本文介绍了在Android的触摸事件的MapView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我用我application.it一个图形页面显示正确,但问题是,当我触摸地图查看其不动,如果用户想查看附近的位置,他不能移动到location.you可以说MapView的不在回应我的layout.here到的TouchEvent是我的布局code

hi i am using a mapview in my application.it showing correctly but the problem is when i touch map view its not moving if a user want to see nearby location he cant move to that location.you can say that mapview is not responding to touchevent in my layout.here is my layout code

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:background="#FFFFFF">
    <TextView
    android:id="@+id/name"
    android:layout_width="fill_parent"
    android:layout_height="50px"
    android:textSize="20sp"
    />
    <TextView
    android:id="@+id/link"
    android:layout_width="fill_parent" 
    android:layout_height="50px" 
    android:autoLink="web"/>
    <TextView
    android:id="@+id/department"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    />
    <TextView
    android:id="@+id/count"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"/>
    <TextView
    android:id="@+id/location"
    android:layout_width="fill_parent"
    android:layout_height="80px" />
    <LinearLayout
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" >
    <TextView
    android:id="@+id/longitude"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_weight="1"/>
    <TextView
    android:id="@+id/latitude"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_weight="1"/>
    </LinearLayout>
    <LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal">
    <Button
    android:id="@+id/zoomin"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_weight="1" 
    android:text="ZoomIn"/>
<Button

android:id="@+id/zoomout"
android:layout_width="wrap_content"
android:layout_height="wrap_content" 
android:layout_weight="1"
android:text="Zoom Out"/>

    </LinearLayout>
    <com.google.android.maps.MapView
    android:id="@+id/mapview"
                 android:layout_width="fill_parent"
                 android:layout_height="wrap_content"
                 android:apiKey="0PmsmqKFKflNmHXD2fwG_vPWnR2gA-YB2QVlIQA"
                 android:layout_weight="2"
                 />

</LinearLayout>

移动到不同的位置,当任的观点是任何位置默认情况下,感动任何一个可以告诉为什么它不动,我应该怎么办,这样的触摸事件,将移动。

moving to different location when any view is any location is touched by default can any one please tell why its not moving and what should i do so that on touch event it will move.

推荐答案

如果我正确地理解你的问题是它当您尝试在地图上四处移动它没有做任何事情。它可能有助于theese两行添加XML中

If i understand your problem correctly its that when you try to move around the map its not doing anything.. It might help to add theese two lines inside your XML

android:enabled="true"
android:clickable="true"

这应该是这样的片段里面:

It should look like this inside your snippet:

<com.google.android.maps.MapView
    android:id="@+id/mapview"
                 android:layout_width="fill_parent"
                 android:layout_height="wrap_content"
                 android:apiKey="0PmsmqKFKflNmHXD2fwG_vPWnR2gA-YB2QVlIQA"
                 android:layout_weight="2"
                 android:enabled="true"
                 android:clickable="true"
                 />

所以尝试的MapView对象添加​​XML里面的两行,它应该工作。

So try add the two lines inside your XML at the MapView object and it should work.

这篇关于在Android的触摸事件的MapView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆