How to set viewFlipper as live wallpaper on a button click in Android Studio
Tutorial step by step with free source code, pictures and video: how to set viewFlipper as live wallpaper on a button click in Android Studio version 1.5.1.
The idea of this project is to have two activities: in first the button, which on click will open the second activity where the slideshow with live wallpapers will start.
Create New Project with Application name: ViewFlipper on Button Click; Minimum SDK: API 10 – Android 2.3.3 (Gingerbread).
Add 5 pictures from your computer, in project folder app->res->drawable: picture1.jpg, picture2.jpg, picture3.jpg, picture4.jpg, picture5.jpg and back.jpg (for background of your app).
Create New Java Class with Name: Slideshow and complete the code:
package com.example.toyo.viewflipperonbuttonclick;
import android.app.Activity;
import android.os.Bundle;
import android.widget.ViewFlipper;
public class Slideshow extends Activity {
ViewFlipper viewFlipper;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_second);
viewFlipper = (ViewFlipper) this.findViewById(R.id.viewFlipper);
//sets auto flipping
viewFlipper.setAutoStart(true);
viewFlipper.setFlipInterval(3000);
viewFlipper.startFlipping();
}
}
Create New XML layout file with Name: activity_second and complete the code by creating a ViewFlipper with 5 ImageView inside:
package com.example.toyo.viewflipperonbuttonclick;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
View v = findViewById(R.id.button);
v.setOnClickListener(this);
}
@Override
public void onClick(View arg0) {
if (arg0.getId() == R.id.button) {
//define a new Intent for the second Activity
Intent intent = new Intent(this, Slideshow.class);
//start the second Activity
this.startActivity(intent);
}
}
}
That’s all!
Run your app in Emulator and see the result: app in opening with a button on background picture and after your click, the slideshow with live wallpapers starts.
See video tutorial:
Download free ClickViewFlipper.apkapplication from hereand install it on your device to see how works.
Check next tutorials to learn all about Android.
For furtherquestionsleave a message.
You can follow any responses to this entry through the RSS 2.0 feed.
Karan Thakkar
Can you please post a tutorial or a series of short videos on how to use google maps api in android studio that is getting last location, change location settings, receive location updates, set marker on map, creating geofence and gecoding?
Can you please post a tutorial or a series of short videos on how to use google maps api in android studio that is getting last location, change location settings, receive location updates, set marker on map, creating geofence and gecoding?
how to sat mobile home screen to sat live wallpaper on button click event.
wallpaper sat mobile screen not application.