Widget - TextSwitcher

final String strTextSwitcher[] = {"Text Switcher 1", "Text Switcher 2", "Text Switcher 3", "Text Switcher 4", "Text Switcher 5"};

final int currentIndex = -1;

final TextSwitcher textSwitcher = new TextSwitcher(MainActivity.this);
textSwitcher.setLayoutParams(new LinearLayout.LayoutParams(android.widget.LinearLayout.LayoutParams.WRAP_CONTENT, android.widget.LinearLayout.LayoutParams.WRAP_CONTENT));
linear1.addView(textSwitcher);


textSwitcher.setFactory(new ViewSwitcher.ViewFactory() {
public View makeView() {
TextView t = new TextView(MainActivity.this);
t.setGravity(Gravity.TOP | Gravity.CENTER);
t.setTextSize(36);

return t;

}

});

textSwitcher.setCurrentText("click Button");


//button prev
button1.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View view) {

if (currentIndex>0)

currentIndex = currentIndex-1;

textSwitcher.setText(strTextSwitcher[currentIndex]);
}

});

//button next
button2.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View view) {

if (currentIndex<strTextSwitcher.length-1)

currentIndex = currentIndex+1;

textSwitcher.setText(strTextSwitcher[currentIndex]);

}

});

Komentar

Cara pembuatan Apps paling Populer

Create Stopwatch App in Android using Sketchware

TextInputLayout in Sketchware

How to find and​ highlight a word in a text field in Sketchware?

A Flash Light App in Sketchware

How to enable download in webview in Sketchware apps?

Intent - Open File By Type

Code for implementing Notifications in Sketchware

How to share an image from Drawable folder?

ActionBar back button

Animation Transtition Animation