Assasin Knight
- Forum-Beiträge: 3
18.02.2019, 22:29:37 via Website
18.02.2019 22:29:37 via Website
Hi,
ich wollte eine eigene Animation in einem Thread erstellen und nach Beendigung soll es weiter gehen. Leider zeigt er nicht die Animation . Weißt jemand wie ich das lösen kann?
mfg
Assasin :-X
MainActivity code:
TextView textbanner = (TextView) findViewById(R.id.meLbl);
ChatAnimation chatAnimation = new ChatAnimation(textbanner);
chatAnimation.start();
//wait for animation
try {
chatAnimation.join();
} catch (InterruptedException e) {
e.printStackTrace();
}
ChatAnimation code:
public class ChatAnimation extends Thread {
private TextView tv;
private int sleeptime = 100;
public ChatAnimation(TextView tv) {
this.tv = tv;
}
public void run() {
int i = 0;
while (i < 4) {
tv.post(new Runnable() {
public void run() {
tv.setText("EVA schreibt");
}
});
try {
sleep(sleeptime);
} catch (InterruptedException e) {
}
tv.post(new Runnable() {
public void run() {
tv.setText("EVA schreibt .");
}
});
try {
sleep(sleeptime);
} catch (InterruptedException e) {
}
tv.post(new Runnable() {
public void run() {
tv.setText("EVA schreibt ..");
}
});
try {
sleep(sleeptime);
} catch (InterruptedException e) {
}
tv.post(new Runnable() {
public void run() {
tv.setText("EVA schreibt ...");
}
});
try {
sleep(sleeptime);
} catch (InterruptedException e) {
}
i++;
}
tv.post(new Runnable() {
public void run() {
tv.setText("EVA");
}
});
}
}
Empfohlener redaktioneller Inhalt
Mit Deiner Zustimmung wird hier ein externer Inhalt geladen.
Mit Klick auf den oben stehenden Button erklärst Du Dich damit einverstanden, dass Dir externe Inhalte angezeigt werden dürfen. Dabei können personenbezogene Daten an Drittanbieter übermittelt werden. Mehr Infos dazu findest Du in unserer Datenschutzerklärung.