2010-07-23 195 views
2

嗨,大家好,我只是想让程序显示main0的布局,并保留几秒钟,然后显示布局main1,就像我们在任何手机上看到的程序一样,在程序开始时显示图像或布局,然后淡入淡出。我怎样才能让android程序显示一个布局,然后几秒钟。并显示另一个布局?

/**the main activity */ 

public class rdwt extends Activity implements OnClickListener{ 

Button b1; 
Button b2; 
/** Called when the activity is first created. */ 
@Override 
public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 

    setContentView(R.layout.main0); 
    //Here 
    setContentView(R.layout.main1); 

    b1= (Button)findViewById(R.id.Button01); 
    b2= (Button)findViewById(R.id.Button02); 
    b1.setOnClickListener(this); 
    b2.setOnClickListener(this); 


} 

    public void onClick(View v) { 
     if (v==this.b1){ 
      Intent callwrite = new Intent(this, wto.class);    
      startActivity(callwrite); 
     } 

     if(v==this.b2){ 
      Intent callread = new Intent(this, rfr.class);    
      startActivity(callread); 
     } 

    } 

}

+0

感谢名单jleedev我真的再次 – SultanSh 2010-07-23 20:04:37

回答

0

我觉得有特别的两种不同的方法。

1)使用android.os.Handler和发送延迟的邮件

2)使用timertimer task的特定时间量

代码示例后更新您的布局:

TimerTask bla = new YourTask(); 
Timer timer = new Timer(); 
timer.schedule(bla, 1000); 

而你的班级YourTask:

public class YourTask extends TimerTask { 

    public void run() { 
    updateYourLayout(); 
    } 

} 

编辑:但是我认为你正在寻找一个闪屏。这个简单的教程将介绍如何做到这一点:http://www.anddev.org/simple_splash_screen-t811.html

+0

感谢您的帮助 感谢名单我怎么能这样做? – SultanSh 2010-07-23 19:50:04

+0

文档非常清晰,但我会编辑我的答案。 – 2010-07-23 19:59:31

+0

Thanx我会试试看。 – SultanSh 2010-07-23 20:07:23

0

//将在下面的一行代码。

timer(3500); // Waits 3.5 seconds before moving on to the next activity. 



    public void timer(int counter){ 
     new Handler().postDelayed(new Runnable(){ 
      @Override 
      // counter is in milliseconds. 
      public void run() {    
       Intent mainIntent = new Intent(THISCLASSNAME.this,CLASSNAMETOJUMPTO.class); 
       startActivity(mainIntent); 
       finish(); 
+0

Thanx我会尝试它 – SultanSh 2010-07-26 18:12:12

相关问题