Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer peopleโ€™s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer peopleโ€™s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8929679
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:43:28+00:00 2026-06-15T08:43:28+00:00

i’m a newbie of android :) I want to create a simple slideshow with

  • 0

i’m a newbie of android ๐Ÿ™‚

I want to create a simple slideshow with a numeric parameter(x) and a button.I have 21 images and, at the click of the button, I want to catch x and “slide” only the first x images of the list.Between one image and the next i want wait 1 second.

At the end i want to know how much time passed during the operation. (sorry for my english)

paste below the code of the activity and the layout:

package com.superpibenchmarknative;

import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;



public class ImageActivity extends Activity implements OnClickListener {
private Button start;
private EditText iteractions;
private TextView time;
private ImageView display;
private long after,before;
private int images[] = {R.drawable.image1,R.drawable.image2,R.drawable.image3,
                        R.drawable.image4,R.drawable.image5,R.drawable.image6,R.drawable.image7,
                        R.drawable.image8,R.drawable.image9,R.drawable.image10,R.drawable.image11,
                        R.drawable.image12,R.drawable.image13,R.drawable.image14,R.drawable.image15,
                        R.drawable.image16,R.drawable.image17,R.drawable.image18,R.drawable.image19,
                        R.drawable.image20,R.drawable.image21,
        };
@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_image);
    setUpUI();
}

private void setUpUI() {
    // TODO Auto-generated method stub
    start = (Button) findViewById(R.id.bntStartCalcolation);
    iteractions = (EditText) findViewById(R.id.etIterations);
    time = (TextView) findViewById(R.id.tvTime);

    start.setOnClickListener(this);
}

@Override
public void onClick(View arg0) {
    //Creo le imageview in base al # di iteractions 
    before = System.currentTimeMillis();
    for (int j = 0; j < Integer.parseInt(iteractions.getText().toString());j++){
        display = (ImageView) findViewById(R.id.ivDisplay);
        display.setImageResource(images[j]);
        Handler handler = new Handler(); 
        handler.postDelayed(new Runnable() { 
             public void run() { 
                  display = null;
                  System.gc();
             } 
        }, 1000); 

    }
    display = null;
    System.gc();
    after = System.currentTimeMillis();
    time.setText(String.valueOf(after-before-1000* Integer.parseInt(iteractions.getText().toString())));
}

}

and this is the layout:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
tools:context=".ImageActivity" >

<TextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_marginBottom="5dp"
    android:layout_marginLeft="15dp"
    android:layout_marginRight="15dp"
    android:layout_marginTop="10dp"
    android:padding="5dp"
    android:text="Benchmark del rendering di immagini" />

<EditText
    android:id="@+id/etIterations"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:layout_marginBottom="5dp"
    android:layout_marginLeft="15dp"
    android:layout_marginRight="15dp"
    android:layout_marginTop="5dp"
    android:hint="# di iterazioni"
    android:inputType="number"
    android:padding="5dp" />

<Button
    android:id="@+id/bntStartCalcolation"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginBottom="5dp"
    android:layout_marginLeft="15dp"
    android:layout_marginRight="5dp"
    android:layout_marginTop="5dp"
    android:text="Start Calcolation" />

<ImageView  android:id="@+id/ivDisplay"
            android:layout_width="200dp"
            android:layout_height="200dp"
            android:layout_gravity="center"/>

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:weightSum="100" >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="15dp"
        android:layout_weight="50"
        android:text="Risultato ottenuto in: " />

    <TextView
        android:id="@+id/tvTime"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="15dp"
        android:layout_weight="50" />
</LinearLayout>

this code dosn’t work, it create an exception

OutOfMemoryError: bitmap size exceed the vm budget

anyone can help me to solve this problem?? ๐Ÿ™‚ thanks at all however ๐Ÿ˜€

great all works ๐Ÿ˜€ but i’ve a little more questions

I don’t understand why the time is always negative!!!
anyone of you know why?? [postDelayed not works?!? ๐Ÿ™ ]

solved with: android.os.SystemClock.sleep(1000);

Another error, the ImageView dosn’t change after the setting of an image, any suggestions??

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T08:43:29+00:00Added an answer on June 15, 2026 at 8:43 am

    There is a small guide within the developer site regarding loading large bitmap files. The idea is to load lower resolution files so that they should fit in memory: http://developer.android.com/training/displaying-bitmaps/load-bitmap.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have just tried to save a simple *.rtf file with some websites and
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
this is what i have right now Drawing an RSS feed into the php,
I have a small JavaScript validation script that validates inputs based on Regex. I
I want use html5's new tag to play a wav file (currently only supported

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.