如何在特定时间段内祝贺消息?

时间:2014-04-02 08:52:42

标签: android toast

我已经为我的谷歌地图制作了一些代码,我将相机定位到一个位置,当相机定位到第一个位置时我将一个消息干脆,然后我将相机移动到另一个位置但问题是吐司动作没有出现足够的时间来阅读消息。反正所以我可以设置吐司让我说10秒钟左右?这是我的代码。

          public void onFinish() {
     LatLng 1= new LatLng(x , y);
     LatLng 2= new LatLng(x , y);                               
GoogleMap map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();                                         
   map.animateCamera(CameraUpdateFactory.zoomTo(10), 30000,null);

Toast.makeText(getBaseContext(), " I want this message to displayed for 10 seconds.",   
 Toast.LENGTH_SHORT)
 .show();

CameraPosition cameraPosition3 = new CameraPosition.Builder()
.target(1)     
.zoom(16)         

.bearing(300)                
.tilt(30)                   
.build();

  map.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition3 ),30000,new  
  CancelableCallback() 

{  public void onFinish() {

 LatLng 2= new LatLng(x, y);

 GoogleMap map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
 map.animateCamera(CameraUpdateFactory.zoomTo(10), 30000,null);
 Toast.makeText(getBaseContext(), " This message for 10 seconds.", Toast.LENGTH_SHORT)                                                
  CameraPosition cameraPosition3 = new CameraPosition.Builder()
 .target(2)     
   .zoom(16)         

  .bearing(300)                
  .tilt(30)                   
   .build();

map.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition3 ),30000,null);

3 个答案:

答案 0 :(得分:1)

试试这肯定会帮助你我已经尝试过了

   final Toast toast = Toast.makeText(getBaseContext(), "YOUR MESSAGE",Toast.LENGTH_SHORT);
                        toast.show();
                        new CountDownTimer(10000, 1000)
                        {
                            public void onTick(long millisUntilFinished) {toast.show();}
                            public void onFinish() {toast.cancel();}
                        }.start();

从这个问题得到了答案,请参阅完整的详细信息

http://stackoverflow.com/questions/2220560/can-an-android-toast-be-longer-than-toast-length-long

答案 1 :(得分:0)

您需要继承Toast类并使用它。默认类只有两个值。即使您通过较长的持续时间,我们也将恢复为SHORT或LONG

答案 2 :(得分:0)

这是你在1000的吐司消息是1秒,然后第3个位置是你的吐司的时间,然后你可以显示te吐司10秒......

   Toast.makeText(getBaseContext(), " This message for 10 seconds.", 10*1000).show();
相关问题