1

我是 Android 新手。我正在做一个关于多播的项目。现在我需要在点击标记时在地图中显示一个气泡。我不需要对话框,需要带有按钮和文本视图的气泡视图。想先显示文本视图。不知道我用这段代码做什么。试了很多次。但没有任何想法。这个是我的 onTap 代码:

            protected boolean onTap(int index)
             {
    System.out.println("Tapped");

    //To display the bubble for robots:
    //LayoutInflater inflater = this.getLayoutInflater();
  //bubble_view = (LinearLayout) inflater.inflate(R.layout.window_view, bubble_view );

 TextView venueName = (TextView) bubble_view.findViewById(R.id.name1);
    venueName.setText("Hello SK");

   GeoPoint rPoint = null;
MapView.LayoutParams params = new MapView.LayoutParams(
        LayoutParams.WRAP_CONTENT, 200,
            rPoint, MapView.LayoutParams.BOTTOM_CENTER);

            bubble_view.setLayoutParams(params);
             System.out.println("sgdhgsetlumstmwejfsd");
     map.addView(bubble_view);

                    Runnable r = new Runnable() {
            public void run() {

                bubble_view.setVisibility(View.VISIBLE);    
                 }
        };
            //Projection projection = ((MapView) map).getProjection();
        //Point p = new Point();

        //projection.toPixels(rPoint, p);
        //p.offset(0, -(bubble_view.getMeasuredHeight() / 2));
        //GeoPoint target = projection.fromPixels(p.x, p.y);

        //mapController = ((MapView) map).getController(); 
        //mapController.setZoom(16);


        //mapController.animateTo(target, r);

    //Toast.makeText( mContext,"Device Name: "+index,Toast.LENGTH_SHORT).show(); 
    //return bubble_view != null;
    return true;
}



private LayoutInflater getLayoutInflater() {
    // TODO Auto-generated method stub
    return null;
}
   }

这是我的代码。它有错误。是 LayoutInflator 仅在 onCreate 中定义。我在此站点中引用的大部分代码:http://www.actionshrimp.com/tag/android-2/

请帮我改正。

4

1 回答 1

1

您可以使用该mapviewballoons库来执行此操作。

于 2012-03-21T12:11:51.953 回答