Comment faire de Chargement 3 dot d'animation dans l'écran de démarrage
Salut, je suis en train de faire ma 1ère application android et j'ai fait un écran de démarrage. Cependant, j'ai essayé d'ajouter de chargement, veuillez patienter en bas avec la période de l'incrément toutes les 2 secondes. Je ne suis pas sûr de savoir comment y arriver parce que l'écran se bloque à cause de ce texte.
final TextView loadingText = (TextView)findViewById(R.id.loading_text);
Thread splashTimer = new Thread(){
public void run(){
try{
int splashTime = 0;
while(splashTime < 6000){
sleep(100);
if(splashTime < 2000){
loadingText.setText("Loading.");
}
else if(splashTime >= 2000 && splashTime < 4000 ){
loadingText.setText("Loading..");
}else if (splashTime >= 4000){
loadingText.setText("Loading...");
}
splashTime = splashTime + 100;
}
Intent intent = new Intent(MainActivity.this,myMainScreen.class);
startActivity(intent);
}catch(InterruptedException e){
e.printStackTrace();
}
finally{
finish();
}
}
};
splashTimer.start();
}
voici mon logcat
06-12 01:36:33.646: D/HyLog(29533): I : /data/font/config/sfconfig.dat, No such file or directory (2)
06-12 01:36:33.646: D/HyLog(29533): I : /data/font/config/dfactpre.dat, No such file or directory (2)
06-12 01:36:33.646: D/HyLog(29533): I : /data/font/config/sfconfig.dat, No such file or directory (2)
06-12 01:36:33.986: I/Adreno-EGL(29533): <qeglDrvAPI_eglInitialize:385>: EGL 1.4 QUALCOMM build: ()
06-12 01:36:33.986: I/Adreno-EGL(29533): OpenGL ES Shader Compiler Version: E031.24.00.02
06-12 01:36:33.986: I/Adreno-EGL(29533): Build Date: 01/20/14 Mon
06-12 01:36:33.986: I/Adreno-EGL(29533): Local Branch: PMH2-KK_3.5-RB1-AU61-554722-586267-set2
06-12 01:36:33.986: I/Adreno-EGL(29533): Remote Branch:
06-12 01:36:33.986: I/Adreno-EGL(29533): Local Patches:
06-12 01:36:33.986: I/Adreno-EGL(29533): Reconstruct Branch:
06-12 01:36:34.026: D/OpenGLRenderer(29533): Enabling debug mode 0
06-12 01:36:34.096: I/ActivityManager(29533): Timeline: Activity_idle id: android.os.BinderProxy@42b1e788 time:14063098
06-12 01:36:34.336: W/dalvikvm(29533): threadid=11: thread exiting with uncaught exception (group=0x41ae6e48)
06-12 01:36:34.336: E/AndroidRuntime(29533): FATAL EXCEPTION: Thread-2388
06-12 01:36:34.336: E/AndroidRuntime(29533): Process: com.sachinda.myfirstapp, PID: 29533
06-12 01:36:34.336: E/AndroidRuntime(29533): android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
06-12 01:36:34.336: E/AndroidRuntime(29533): at android.view.ViewRootImpl.checkThread(ViewRootImpl.java:6347)
06-12 01:36:34.336: E/AndroidRuntime(29533): at android.view.ViewRootImpl.requestLayout(ViewRootImpl.java:871)
06-12 01:36:34.336: E/AndroidRuntime(29533): at android.view.View.requestLayout(View.java:16472)
06-12 01:36:34.336: E/AndroidRuntime(29533): at android.view.View.requestLayout(View.java:16472)
06-12 01:36:34.336: E/AndroidRuntime(29533): at android.view.View.requestLayout(View.java:16472)
06-12 01:36:34.336: E/AndroidRuntime(29533): at android.view.View.requestLayout(View.java:16472)
06-12 01:36:34.336: E/AndroidRuntime(29533): at android.widget.RelativeLayout.requestLayout(RelativeLayout.java:352)
06-12 01:36:34.336: E/AndroidRuntime(29533): at android.view.View.requestLayout(View.java:16472)
06-12 01:36:34.336: E/AndroidRuntime(29533): at android.widget.TextView.checkForRelayout(TextView.java:6817)
06-12 01:36:34.336: E/AndroidRuntime(29533): at android.widget.TextView.setText(TextView.java:3947)
06-12 01:36:34.336: E/AndroidRuntime(29533): at android.widget.TextView.setText(TextView.java:3805)
06-12 01:36:34.336: E/AndroidRuntime(29533): at android.widget.TextView.setText(TextView.java:3780)
06-12 01:36:34.336: E/AndroidRuntime(29533): at com.sachinda.myfirstapp.MainActivity$1.run(MainActivity.java:45)
06-12 01:36:36.316: I/Process(29533): Sending signal. PID: 29533 SIG: 9
- Publier vos logcat
Vous devez vous connecter pour publier un commentaire.
C'est s'écraser parce que vous êtes en train de modifier composant de l'interface utilisateur sur un autre thread d'INTERFACE utilisateur ajouter une méthode comme
et modifier votre code pour utiliser cette méthode
Ce que vous faites ici, c'est la mise à jour de l'INTERFACE utilisateur éléments à l'intérieur d'un fil, qui n'est pas autorisé!
Ce que vous avez à faire est d'utiliser des Gestionnaires:
Cela permettra de résoudre le but.
Salut, je suis en retard pour répondre, mais ce sera certainement aider quelqu'un d'autre, ce simple de la Bibliothèque - https://github.com/rajputkapil/textviewdotsanimation disponible sur
github
peut vous aider à montrer à 3 points de l'animation en appelant simplement sa classe de vue personnaliséeTextAndAnimationView
, comte de points peut être augmenté ou diminué, juste en appelantapp:numberOfDots="count of dots in Integer"