Reputation: 169
In my application , i am displaying a splash screen that i want to make touchscreen and display the next activity .I am a beginner please help me
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);
}
}
Upvotes: 0
Views: 780
Reputation: 7605
inside oncreat() method add this
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();
}
}
here YourSecondActivity is the Activity in which u want to go from Splash Screen
Upvotes: 2
Reputation: 1404
Try this, It will display spalsh screen in period of time or exit on touch
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();
}
Upvotes: 1
Reputation: 4284
Inside onCreate()
::
LinearLayout layout = (LinearLayout) findViewById(R.id.layout);//In your xml file, main xml layout android:id="@+id/layout"
layout.setOnClickListener(this);
add onclick method
@Override
public void onClick(View arg0) {
Intent intent = new Intent(this, NewActivityToStart.class);
startActivity(intent);
}
Upvotes: 1
Reputation: 11
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);
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent i=new Intent(this,<NewActivity>.class);
startActivity(i);
finish();
}
}
Upvotes: 0
Reputation: 7184
You are on the right way. You just need to add the onClick method and start the next activity:
@Override
public void onClick(View v) {
// Start next activity
}
Upvotes: 0