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

  • Home
  • SEARCH
  • 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 3437084
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T08:01:18+00:00 2026-05-18T08:01:18+00:00

This is my .java file in src: package com.wao.texttime; import java.util.Calendar; import android.app.Activity; import

  • 0

This is my .java file in src:

package com.wao.texttime;

import java.util.Calendar;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

public class TextTime extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        TextView textView = (TextView) findViewById(R.id.TextView01);
        Calendar cal = Calendar.getInstance();
        cal.setTimeInMillis(System.currentTimeMillis());

        cal.set(Calendar.HOUR_OF_DAY, 6);
        cal.set(Calendar.MINUTE, 15);
        cal.set(Calendar.SECOND, 0);

        long vask_1 = cal.getTimeInMillis();

        cal.set(Calendar.HOUR_OF_DAY, 10);
        cal.set(Calendar.MINUTE, 0);
        cal.set(Calendar.SECOND, 0);

        long vask_2 = cal.getTimeInMillis();

        cal.set(Calendar.HOUR_OF_DAY, 14);
        cal.set(Calendar.MINUTE, 0);
        cal.set(Calendar.SECOND, 0);

        long vask_3 = cal.getTimeInMillis();

        cal.set(Calendar.HOUR_OF_DAY, 16);
        cal.set(Calendar.MINUTE, 0);
        cal.set(Calendar.SECOND, 0);

        long vask_4 = cal.getTimeInMillis();

        cal.set(Calendar.HOUR_OF_DAY, 19);
        cal.set(Calendar.MINUTE, 0);
        cal.set(Calendar.SECOND, 0);

        long vask_5 = cal.getTimeInMillis();
        long now = System.currentTimeMillis();

        if(now > vask_1 && now < vask_2)
        {
            textView.setText("5");
        }
        else if(now > vask_2 && now < vask_3)
        {
            textView.setText("1");
        }
        else if(now > vask_3 && now < vask_4)
        {
            textView.setText("2");
        }
        else if(now > vask_4 && now < vask_5)
        {
            textView.setText("3");

    }
    }
    }

I’ve been told I can use the OnResume to reload the current time to update the text in the TextView. But, I don’t know how to use it in the file. Do you have 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-05-18T08:01:19+00:00Added an answer on May 18, 2026 at 8:01 am

    After the closing } of your onCreate method, add this:

    @Override
    protected void onResume(){
        super.onResume();
        // code to update the date here
    }
    

    You will also have to move the declarations of your TextView outside the onCreate method, or at least you will probably want to. To do this, add a line like this before the onCreate method:

    private TextView textView;
    

    and then in your onCreate you just need this:

    textView = (TextView) findViewById(R.id.TextView01);
    

    Then you can access textView from your onResume method too.

    Hope that helps.

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

Sidebar

Related Questions

This is my .java file in src: package com.wao.texttime; import android.app.Activity; import android.os.Bundle; import
The top of my web.xml file looks like this: <?xml version=1.0 encoding=UTF-8?> <web-app xmlns=http://java.sun.com/xml/ns/j2ee
I have this java code: <script src=http://www.google.com/jsapi></script> <script type=text/javascript> google.load(jquery, 1.2.6); $(a#more).click(function() { $(#info_box).show(blind,
How to read a web server log file in Java. This file is getting
Can I write to the end of a 5GB file in Java? This question
I have this Maven task to generate Java classes from an XSD file using
I have a Java project which has this file structure (shown in Eclipse): ProjectName
I'm trying to compile ActionFactory.java file which imports one of my package, RegisterAction.java Here
In my SVN java source files are under src/java/com/... location. When I create the
How can I make this java generic cast ? public interface IField { }

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.