Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

120
Views
Android muestra imágenes de la carpeta secuencialmente

Tengo un leve problema. Tengo 27 imágenes, con nombres de archivo img0001 hasta img00027, ¿cómo hago para que se reproduzcan en secuencia? Como actualmente reproduce img0001, img00010 -> img00019, img0002 -> img00027.

Esto es lo que tengo en MainActivity.java para manejar el cambio entre imágenes:

 @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); imageView = (ImageView) findViewById(R.id.imageView); Field[] drawables = R.drawable.class.getFields(); for (Field f : drawables) { if (f.getName().contains("img")) imageArrayList.add(getResources().getIdentifier(f.getName(), "drawable", getPackageName())); } } protected void onStart() { super.onStart(); final Handler handler = new Handler(); Runnable runnable = new Runnable() { int i = 0; @Override public void run() { imageView.setImageResource(imageArrayList .get(i)); Animation fade = AnimationUtils.loadAnimation(MainActivity.this, R.anim.fade_intervals); imageView.startAnimation(fade); i++; if (i > imageArrayList.size() - 1) { i = 0; } handler.postDelayed(this, 4000); // for interval images } }; handler.postDelayed(runnable, 8000); // for initial image }

Cualquier ayuda sería apreciada. Me he cansado con solo 9 imágenes, img0001-img0009 y funciona bien. Siento que es un problema de nombre de archivo, pero no estoy seguro de cómo solucionarlo.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Como dijiste, es un problema de nombre de archivo. Los archivos se ordenan alfanuméricamente, debe ordenar imageArrayList según sus necesidades. Por lo tanto, al implementar un Comparator ( preguntado aquí ), también debe considerar esto .

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!