创建图形页面具有文本菜单不重叠

编程入门 行业动态 更新时间:2024-10-13 18:25:17
本文介绍了创建图形页面具有文本菜单不重叠的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个图形窗口和我想显示一个文本菜单时longclick但到目前为止最接近的解决方案,我发现的是的在这里anddev ,最主要的原因,我不喜欢这种方法,因为任何点击激活文本菜单,而不是长时间点击。

I have a mapview and i wish to display a ContextMenu when longclick but so far the closest solution i've found is here on anddev , the main reason i do not like that method is because any click activate the ContextMenu instead of a long click.

问:

有没有办法来显示地图的文本菜单不使用叠加?为什么呢?

Is there a way to display the ContextMenu of a Map without using Overlays? Why?

推荐答案

这是我使用的方法。我创建了扩展MapActivity了AbstractMap类。在这里,我再从AbstractMap类扩展到创建一个适合我的需求的地图。注意:我只用了这种方法,因为我需要几个地图与我的应用程序不同的属性。你可以简单地从AbstractMap删除摘要关键字,直接覆盖这个类中的OnGestureListener方法和实例化。

This is the approach I used. I created an AbstractMap class which extended MapActivity. From here I then extended from the AbstractMap class to create a Map which suited my requirements. Note I only used this approach since I was requiring several maps with varying properties for my application. You could simply remove the Abstract keyword from the AbstractMap, directly override the OnGestureListener methods within this class and instantiate it.

下面是AbstractMap类

Here is the AbstractMap class

public abstract class AbstractMap extends MapActivity implements OnGestureListener, OnDoubleTapListener { public MapView mapView; public MapController mapController; public List<Overlay> mapOverlays; private GestureDetector detector; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); try { requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.mapp); detector = new GestureDetector(this, this); mapView = (MapView) findViewById(R.id.mapview); mapView.setOnTouchListener(otl); mapController = mapView.getController(); mapOverlays = mapView.getOverlays(); } catch (Exception e) { Log.e("Error", "Exception", e); } } public OnTouchListener otl = new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (detector.onTouchEvent(event)) return true; else return false; } };

}

下面是朗pressMap

Here is the LongPressMap

public class LongPressMap extends AbstractMap { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); } @Override public boolean onDown(MotionEvent event) { return false; } public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,float velocityY) { return false; } @Override public void onLongPress(MotionEvent e) { } @Override public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { //Log.d("Debug","On Scrtoll"); // TODO Auto-generated method stub return false; } @Override public void onShowPress(MotionEvent e) { } @Override public boolean onSingleTapUp(MotionEvent e) { return false; } @Override public boolean onDoubleTap(MotionEvent e) { return false; } @Override public boolean onDoubleTapEvent(MotionEvent e) { // TODO Auto-generated method stub return false; } @Override public boolean onSingleTapConfirmed(MotionEvent e) { // TODO Auto-generated method stub return false; } @Override protected boolean isRouteDisplayed() { // TODO Auto-generated method stub return false; }

}

希望这有助于。

更多推荐

创建图形页面具有文本菜单不重叠

本文发布于:2023-11-02 03:42:05,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1551269.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:图形   菜单   文本   页面

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!