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 6039495
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:22:37+00:00 2026-05-23T06:22:37+00:00

I am creating an app that requires a ListView with an undetermined number of

  • 0

I am creating an app that requires a ListView with an undetermined number of elements, each of which has a timer that counts down from a variable number. I am able to successfully make one of them count down, but I can’t figure out how to include a timer in each element of the ListView.

I am currently using a CountDownTimer (make sure to capitalize the D if copying from the website, they have it wrong).

Any code or sources to point me in the right direction are much appreciated.

Here is my current EventAdapter class, it sets the text displayed in each ListView element’s TextView. What I need to do is make the TextView count down every second. Since each element of the ListView is displaying something different, I suppose I need a way of differentiating each element.

I could just update the whole list every second, but there are other elements I have not included such as images loaded from the internet that it would be impractical to refresh every second.

private class EventAdapter extends ArrayAdapter<Event>
{
    private ArrayList<Event> items;

    public EventAdapter(Context context, int textViewResourceId, ArrayList<Event> items) {
        super(context, textViewResourceId, items);
        this.items = items;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View v = convertView;
        if (v == null) {
            LayoutInflater vi = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            v = vi.inflate(R.layout.row, null);
        }

        Event e = items.get(position);

        if (e != null) {
            TextView tv = (TextView) v.findViewById(R.id.text);

            if (tv != null)
                tv.setText(e.getName());
        }
        return v;
    }
}
  • 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-05-23T06:22:37+00:00Added an answer on May 23, 2026 at 6:22 am

    Please have a look here at my blog where you will find an example on how to achieve this.

    One solution is to put the TextView that represents each counter into a HashMap together with it’s position in the list as the key.

    In getView()

    TextView counter = (TextView) v.findViewById(R.id.myTextViewTwo);
    if (counter != null) {
        counter.setText(myData.getCountAsString());
        // add the TextView for the counter to the HashMap.
        mCounterList.put(position, counter);
    }
    

    Then you can update the counters by using a Handler and where you post a runnable.

    private final Runnable mRunnable = new Runnable() {
        public void run() {
            MyData myData;
            TextView textView;
    
            // if counters are active
            if (mCountersActive) {                
                if (mCounterList != null && mDataList != null) {
                    for (int i=0; i < mDataList.size(); i++) {
                        myData = mDataList.get(i);
                        textView = mCounterList.get(i);
                        if (textView != null) {
                            if (myData.getCount() >= 0) {
                                textView.setText(myData.getCountAsString());
                                myData.reduceCount();
                            }
                        }
                    }
                }
                // update every second
                mHandler.postDelayed(this, 1000);
            }
        }
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Right now I'm creating a web-app which requires that multiple sets of data (including
I am creating a web app that requires me to render new elements on
I'm creating an android app that requires database connectivity, for which I'm using the
I am creating an app that requires some settings to be set first before
I am in the process of creating an iPhone app that requires to interact
I am new at Mac OSx development. The app that I am creating requires
I am creating an app that alerts user if he has been stationary for
I am creating an app that requires the user to type into an EditText.
I'm currently in the midst of creating an app that requires a very nifty
I'm creating an app for a client that requires French content to be displayed

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.