在我的应用程序中,我显示了一个闪屏,我想要制作触摸屏并显示下一个活动.I我是初学者,请帮助我
package com.integrated.mpr;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class SensitiveFinalActivity extends Activity implements OnClickListener {
/** Called when the activity is first created. */
Button startSensitive;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}发布于 2012-06-02 17:53:06
在oncreat()方法中添加以下内容
LinearLayout layout = (LinearLayout) findViewById(R.id.layout);//In your xml file, main xml layout android:id="@+id/layout"
layout.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
// TODO Auto-generated method stub
Intent i=new Intent(SensitiveFinalActivity.this,YourSecondActivity.class);
startActivity(i);
finish();
}
}这里的YourSecondActivity是你想要从闪屏转到的活动
发布于 2012-06-02 17:19:29
onCreate()内部::
LinearLayout layout = (LinearLayout) findViewById(R.id.layout);//In your xml file, main xml layout android:id="@+id/layout"
layout.setOnClickListener(this); 添加onclick方法
@Override
public void onClick(View arg0) {
Intent intent = new Intent(this, NewActivityToStart.class);
startActivity(intent);
}发布于 2012-06-02 17:23:41
试一下,它会在一段时间内显示spalsh屏幕或在触摸时退出
Thread mSplashThread = new Thread() {
@Override
public void run() {
try {
synchronized (this) {
// Wait given period of time or exit on touch
wait(3000);//ms
}
} catch (InterruptedException ex) {
}
startActivity(new Intent(getApplicationContext(),
YOUR_ACTIVITY.class));
finish();
}
};
mSplashThread.start();
}https://stackoverflow.com/questions/10861100
复制相似问题