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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:17:05+00:00 2026-05-26T19:17:05+00:00

I am trying to get a time stamp into a textview or any view

  • 0

I am trying to get a time stamp into a textview or any view for the matter in an activity that will give the time when the activity is opened from a button plus display the input from two edit text’s into text view’s that are in seperate activities. For example:

Activity Main:

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class MainActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        Button b = (Button) findViewById(R.id.button1);
        b.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {

            }
        });
    }
}

Which includes this xml layout and views:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/hello" />

    <EditText
        android:id="@+id/editText1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" >

        <requestFocus />
    </EditText>

    <EditText
        android:id="@+id/editText2"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" />

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Button" />

</LinearLayout>

Now I want to get the user input from these two edit text’s while opening this next activity with the onClick from the button plus display the time stamp from the time the button was clicked:

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

public class Main2 extends Activity{

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main2);
    }


}

Which inflates this xml layout:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/textView1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="TextView" android:textSize="20dp"/>

    <TextView
        android:id="@+id/textView2"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="TextView" android:textSize="20dp"/>

    <TextView
        android:id="@+id/textView3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="TextView" />

</LinearLayout>

So I want to accomplish the following:

         editText1        ----------->          textView1
         editText2        ----------->          textView2
                       Phone's time stamp       textview3

and open Main2 activity with the click of the button. So editText1 is an EditText that will take user input and return that value into textView1, the same for editText2 and textView2, but on top of that I want to get the time the button is clicked and the time returned into textView3.

Now I know how to return the value of one edittext to a textview in another activity but not two and get a time stamp.

LAS_VEGAS
OK I got the two identifiers to work but getting an error on the time stamp here is what I have as far as code :

This is what I have in the first Activities onClick method:

EditText edit = (EditText) findViewById(R.id.etTitle);
            EditText editP = (EditText) findViewById(R.id.etPrice);
            long currentTime = System.currentTimeMillis();

            Intent intent = new Intent(Post.this, PostSet.class);
            intent.putExtra("com.main.espress.POSTSET",                         `edit.getText().toString());`
            intent.putExtra("com.main.espress.NEW",      editP.getText().toString());
            intent.putExtra("currentTime", currentTime);
            startActivity(intent);

This is what my second Activity has:

TextView tv1 = (TextView) findViewById (R.id.tvTitleText);
        TextView tv2 = (TextView) findViewById (R.id.tvPrice);
        TextView tv3 = (TextView) findViewById (R.id.tvTimeStamp);

        Intent intent = getIntent();
        String edit = intent.getStringExtra("com.main.express.POSTSET");
        String editP = intent.getStringExtra("com.main.espress.NEW");
        long currentTime = extras.getLong("currentTime");

        tv1.setText(edit);
        tv2.setText(editP);
        tv3.setText(currentTime);
  • 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-26T19:17:05+00:00Added an answer on May 26, 2026 at 7:17 pm

    You can pass multiple values of data between activities using Intent:

    Inside onClick()

    EditText et1 = (EditText) findViewById(R.id.editText1);
    EditText et2 = (EditText) findViewById(R.id.editText2);
    long currentTime = System.currentTimeInMillis();
    
    Intent i = new Intent(MainActivity.this, Main2.class);
    i.putExtra("editText1", et1.getText());
    i.putExtra("editText2", et2.getText());
    i.putExtra("currentTime", currentTime);
    startActivity(i);
    

    In Activitiy Main2:

    Bundle extras = getIntent().getExtras();
    String text1 = extras.getString("editText1");
    String text2 = extras.getString("editText2");
    long currentTime = extras.getLong("currentTime");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to get the unix time for date strings that are formatted like
I'm a long time C++/Java developer trying to get into Python and am looking
I'm trying to get some data from my database, and then pass it into
When I'm trying to get the idle time of the gnome screensaver in seconds,
When trying to get geolocation on iPhone the first time - I declined. Every
I'm just trying to get MySQL to store time in GMT... I've read the
I'm trying to get a class memeber variable list at run time. I know
I'm having a hard time trying to get my team comfortable with interface based
I've spent too much time trying to get this to work on IE 7.
I am having a terrible time trying to get an input box like the

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.