[android-developers] Re: date and time

2011-11-02 Thread leigh8347
The peice of code im using to disply the date and time is as follows

datetime.toString()

but like i said this does not update
regards


On Nov 2, 12:02 am, Lew lewbl...@gmail.com wrote:
 leigh8347 wrote:

  im [sic] making an app that writes to a .txt file and at the end of each
  save i want to put the date and time.

  this is my code that turns the time/date into a string. which works
  fine.

  SimpleDateFormat dateFormat = new SimpleDateFormat(dd/MM/
  hh:mm:ss);
  java.util.Date date = new java.util.Date();
  final String datetime = dateFormat.format(date);

  The problem im [sic] having is every time i save the time does not update.
  each row has the same time and date?

 Sounds like you are using the same 'datetime' reference for each save,
 perhaps by doing the save at the end of a longer process?

 It's impossible to say since the problem is in the code you have not shown.

 http://sscce.org/
 please

 --
 Lew

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Re: date and time

2011-11-02 Thread Robert Slama
try add follow line before format to string :
date.setTime(System.currentTimeMillis());

r^

On 2 November 2011 10:44, leigh8347 leigh8...@aol.com wrote:

 The peice of code im using to disply the date and time is as follows

 datetime.toString()

 but like i said this does not update
 regards


 On Nov 2, 12:02 am, Lew lewbl...@gmail.com wrote:
  leigh8347 wrote:
 
   im [sic] making an app that writes to a .txt file and at the end of
 each
   save i want to put the date and time.
 
   this is my code that turns the time/date into a string. which works
   fine.
 
   SimpleDateFormat dateFormat = new SimpleDateFormat(dd/MM/
   hh:mm:ss);
   java.util.Date date = new java.util.Date();
   final String datetime = dateFormat.format(date);
 
   The problem im [sic] having is every time i save the time does not
 update.
   each row has the same time and date?
 
  Sounds like you are using the same 'datetime' reference for each save,
  perhaps by doing the save at the end of a longer process?
 
  It's impossible to say since the problem is in the code you have not
 shown.
 
  http://sscce.org/
  please
 
  --
  Lew

 --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en


-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: date and time

2011-11-02 Thread leigh8347
Thank you but this did not work. Any other ideas

regards

On Nov 2, 11:04 am, Robert Slama robsl...@gmail.com wrote:
 try add follow line before format to string :
 date.setTime(System.currentTimeMillis());

 r^

 On 2 November 2011 10:44, leigh8347 leigh8...@aol.com wrote:







  The peice of code im using to disply the date and time is as follows

  datetime.toString()

  but like i said this does not update
  regards

  On Nov 2, 12:02 am, Lew lewbl...@gmail.com wrote:
   leigh8347 wrote:

im [sic] making an app that writes to a .txt file and at the end of
  each
save i want to put the date and time.

this is my code that turns the time/date into a string. which works
fine.

SimpleDateFormat dateFormat = new SimpleDateFormat(dd/MM/
hh:mm:ss);
java.util.Date date = new java.util.Date();
final String datetime = dateFormat.format(date);

The problem im [sic] having is every time i save the time does not
  update.
each row has the same time and date?

   Sounds like you are using the same 'datetime' reference for each save,
   perhaps by doing the save at the end of a longer process?

   It's impossible to say since the problem is in the code you have not
  shown.

  http://sscce.org/
   please

   --
   Lew

  --
  You received this message because you are subscribed to the Google
  Groups Android Developers group.
  To post to this group, send email to android-developers@googlegroups.com
  To unsubscribe from this group, send email to
  android-developers+unsubscr...@googlegroups.com
  For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Re: date and time

2011-11-02 Thread Kostya Vasilyev

The date / time conversion variations you posted all seem Ok.

If the issue is with how you update the file, look for a bug there, not 
in date formatting.


-- Kostya

02.11.2011 22:59, leigh8347 пишет:

Thank you but this did not work. Any other ideas

regards


--
Kostya Vasilyev

--
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: date and time

2011-11-02 Thread leigh8347
well

here is the code for file update but this seems to work fine.

public void onClick(View v) {
try {
BufferedWriter out = new BufferedWriter(new 
FileWriter(/sdcard/
data_file.txt, true));
out.write(A + txtData.getText() + , + P +
txtData2.getText() + , + datetime.toString());
out.write(\r\n);
out.close();

Toast.makeText(getBaseContext(),Saved,Toast.LENGTH_SHORT).show();
} catch (Exception e) {
Toast.makeText(getBaseContext(), e.getMessage(),
Toast.LENGTH_SHORT).show();
}

txtData.setText();
txtData2.setText();

}



On Nov 2, 7:22 pm, Kostya Vasilyev kmans...@gmail.com wrote:
 The date / time conversion variations you posted all seem Ok.

 If the issue is with how you update the file, look for a bug there, not
 in date formatting.

 -- Kostya

 02.11.2011 22:59, leigh8347 пишет:

  Thank you but this did not work. Any other ideas

  regards

 --
 Kostya Vasilyev

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Re: date and time

2011-11-02 Thread Kostya Vasilyev
In this snippet, you're not re-initializing datetime to the current 
time, so it's going to keep the same value you assigned to it earlier 
(in onCreate?), no matter how many times you click the button.


Oh, and rather than getBaseContext(), use your activity 
class.class or v.getContext().


-- Kostya

02.11.2011 23:39, leigh8347 пишет:

well

here is the code for file update but this seems to work fine.

public void onClick(View v) {
try {
BufferedWriter out = new BufferedWriter(new 
FileWriter(/sdcard/
data_file.txt, true));
out.write(A + txtData.getText() + , + P +
txtData2.getText() + , + datetime.toString());
out.write(\r\n);
out.close();

Toast.makeText(getBaseContext(),Saved,Toast.LENGTH_SHORT).show();
} catch (Exception e) {
Toast.makeText(getBaseContext(), e.getMessage(),
Toast.LENGTH_SHORT).show();
}

txtData.setText();
txtData2.setText();

}



On Nov 2, 7:22 pm, Kostya Vasilyevkmans...@gmail.com  wrote:

The date / time conversion variations you posted all seem Ok.

If the issue is with how you update the file, look for a bug there, not
in date formatting.

-- Kostya

02.11.2011 22:59, leigh8347 пишет:


Thank you but this did not work. Any other ideas
regards

--
Kostya Vasilyev


--
Kostya Vasilyev

--
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: date and time

2011-11-02 Thread leigh8347
I will look into that

Thank you for your help so far, might need to come back if i cant
figure it out.

regards


On Nov 2, 7:48 pm, Kostya Vasilyev kmans...@gmail.com wrote:
 In this snippet, you're not re-initializing datetime to the current
 time, so it's going to keep the same value you assigned to it earlier
 (in onCreate?), no matter how many times you click the button.

 Oh, and rather than getBaseContext(), use your activity
 class.class or v.getContext().

 -- Kostya

 02.11.2011 23:39, leigh8347 пишет:









  well

  here is the code for file update but this seems to work fine.

  public void onClick(View v) {
             try {
                 BufferedWriter out = new BufferedWriter(new 
  FileWriter(/sdcard/
  data_file.txt, true));
                 out.write(A + txtData.getText() + , + P +
  txtData2.getText() + , + datetime.toString());
                 out.write(\r\n);
                 out.close();

  Toast.makeText(getBaseContext(),   Saved,Toast.LENGTH_SHORT).show();
             } catch (Exception e) {
                     Toast.makeText(getBaseContext(), e.getMessage(),
                                     Toast.LENGTH_SHORT).show();
             }

                     txtData.setText();
                     txtData2.setText();

     }

  On Nov 2, 7:22 pm, Kostya Vasilyevkmans...@gmail.com  wrote:
  The date / time conversion variations you posted all seem Ok.

  If the issue is with how you update the file, look for a bug there, not
  in date formatting.

  -- Kostya

  02.11.2011 22:59, leigh8347 пишет:

  Thank you but this did not work. Any other ideas
  regards
  --
  Kostya Vasilyev

 --
 Kostya Vasilyev

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: date and time

2011-11-01 Thread Lew
leigh8347 wrote:

 im [sic] making an app that writes to a .txt file and at the end of each 
 save i want to put the date and time. 

 this is my code that turns the time/date into a string. which works 
 fine. 

 SimpleDateFormat dateFormat = new SimpleDateFormat(dd/MM/ 
 hh:mm:ss); 
 java.util.Date date = new java.util.Date(); 
 final String datetime = dateFormat.format(date); 

 The problem im [sic] having is every time i save the time does not update. 
 each row has the same time and date? 


Sounds like you are using the same 'datetime' reference for each save, 
perhaps by doing the save at the end of a longer process?

It's impossible to say since the problem is in the code you have not shown.

http://sscce.org/
please

-- 
Lew

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: Date AND Time Picker

2009-07-31 Thread Jack Ha

There's no built-in date/time combo widget.

You can do something like this:

LinearLayout
xmlns:android=http://schemas.android.com/apk/res/android;
android:orientation=vertical
android:layout_width=fill_parent
android:layout_height=wrap_content
DatePicker
android:id=@+id/date_picker
android:layout_width=wrap_content
android:layout_height=wrap_content /
TimePicker
android:id=@+id/time_picker
android:layout_width=wrap_content
android:layout_height=wrap_content/
/LinearLayout


--
Jack Ha
Open Source Development Center
・T・ ・ ・Mobile・ stick together

The views, opinions and statements in this email are those of
the author solely in their individual capacity, and do not
necessarily represent those of T-Mobile USA, Inc.




On Jul 31, 4:29 am, Brad Gies rbg...@gmail.com wrote:
 I think I asked this a few months ago, but didn't receive an answer.

 Has anyone done a combination Date AND Time Picker that fits on one screen?
 What I'm looking for is something that looks like the built in Android Date
 picker with the Time Picker below it and the Set/Cancel buttons below that.

 Is there an open source widget like that? I really don't want to create my
 own if I don't have to.

 Thanks for any help.

 Sincerely,

 Brad Gies

 -

 Brad Gies

 27415 Greenfield Rd, # 2,

 Southfield, MI, USA

 48076

 www.bgies.com www.truckerphone.com

 www.EDI-Easy.com www.EDI-Simple.com

 -

 Moderation in everything, including abstinence
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Date and time pickers in an XML layout file - how to get to work?

2008-04-09 Thread NTR

They were also inside a LinearLayout, and a ScrollView:

ScrollView
android:layout_width=fill_parent
android:layout_height=fill_parent
xmlns:android=http://schemas.android.com/apk/res/android;

LinearLayout
android:id=@+id/wtb_layout
android:layout_width=fill_parent
android:layout_height=fill_parent
xmlns:android=http://schemas.android.com/apk/res/android;
android:orientation=vertical
android:padding=7px

 !-- the above layouts here --
/LinearLayout
/ScrollView

Though there's quite a lot of other stuff above them, but nothing that
should matter, as they aren't parents of those views.

Dan U. wrote:
 I put those within a LinearLayout and it worked fine. Can you post
 more of your layout and/or code?

 On a side note, I notice DatePicker likes to throw null pointers
 during onKey.

 On Apr 8, 2:17 pm, NTR [EMAIL PROTECTED] wrote:
  I've tried including date and time pickers in the XML file, like the
  following:
 
  DatePicker
  xmlns:android=http://schemas.android.com/apk/res/android;
  android:layout_width=wrap_content
  android:layout_height=wrap_content
  /
 
  TimePicker
  android:id=@+id/wtb_event_time
  android:layout_width=wrap_content
  android:layout_height=wrap_content
  /
 
  But I get:
 
  ERROR/AndroidRuntime(2930): Caused by: java.lang.RuntimeException:
  Binary XML file line #40: You must supply a layout_width attribute.
  ERROR/AndroidRuntime(2930): at android.content.Resources
  $StyledAttributes.getLayoutDimension(Resources.java:1247)
  ERROR/AndroidRuntime(2930): at android.view.ViewGroup
  $LayoutParams.setBaseAttributes(ViewGroup.java:2641)
  ERROR/AndroidRuntime(2930): at android.view.ViewGroup
  $LayoutParams.init(ViewGroup.java:2605)
  ERROR/AndroidRuntime(2930): at
  android.view.ViewGroup.generateLayoutParams(ViewGroup.java:2101)
  ERROR/AndroidRuntime(2930): at
  android.view.ViewInflate.inflate(ViewInflate.java:358)
  ERROR/AndroidRuntime(2930): at
  android.view.ViewInflate.inflate(ViewInflate.java:292)
  ERROR/AndroidRuntime(2930): at
  android.view.ViewInflate.inflate(ViewInflate.java:241)
 
  There is a layout_width attribute, so what's wrong? I've tried putting
  only one of those views inside of a layout file, and even if the
  Eclipse Android project doesn't complain, the emulator does.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Date and time pickers in an XML layout file - how to get to work?

2008-04-09 Thread NTR

It's also clear that the exceptions are caused by those views, since
whenever I comment them out, everything works just fine.

NTR wrote:
 They were also inside a LinearLayout, and a ScrollView:

 ScrollView
   android:layout_width=fill_parent
   android:layout_height=fill_parent
   xmlns:android=http://schemas.android.com/apk/res/android;

 LinearLayout
   android:id=@+id/wtb_layout
   android:layout_width=fill_parent
   android:layout_height=fill_parent
   xmlns:android=http://schemas.android.com/apk/res/android;
   android:orientation=vertical
   android:padding=7px
   
  !-- the above layouts here --
 /LinearLayout
 /ScrollView

 Though there's quite a lot of other stuff above them, but nothing that
 should matter, as they aren't parents of those views.

 Dan U. wrote:
  I put those within a LinearLayout and it worked fine. Can you post
  more of your layout and/or code?
 
  On a side note, I notice DatePicker likes to throw null pointers
  during onKey.
 
  On Apr 8, 2:17 pm, NTR [EMAIL PROTECTED] wrote:
   I've tried including date and time pickers in the XML file, like the
   following:
  
   DatePicker
   xmlns:android=http://schemas.android.com/apk/res/android;
   android:layout_width=wrap_content
   android:layout_height=wrap_content
   /
  
   TimePicker
   android:id=@+id/wtb_event_time
   android:layout_width=wrap_content
   android:layout_height=wrap_content
   /
  
   But I get:
  
   ERROR/AndroidRuntime(2930): Caused by: java.lang.RuntimeException:
   Binary XML file line #40: You must supply a layout_width attribute.
   ERROR/AndroidRuntime(2930): at android.content.Resources
   $StyledAttributes.getLayoutDimension(Resources.java:1247)
   ERROR/AndroidRuntime(2930): at android.view.ViewGroup
   $LayoutParams.setBaseAttributes(ViewGroup.java:2641)
   ERROR/AndroidRuntime(2930): at android.view.ViewGroup
   $LayoutParams.init(ViewGroup.java:2605)
   ERROR/AndroidRuntime(2930): at
   android.view.ViewGroup.generateLayoutParams(ViewGroup.java:2101)
   ERROR/AndroidRuntime(2930): at
   android.view.ViewInflate.inflate(ViewInflate.java:358)
   ERROR/AndroidRuntime(2930): at
   android.view.ViewInflate.inflate(ViewInflate.java:292)
   ERROR/AndroidRuntime(2930): at
   android.view.ViewInflate.inflate(ViewInflate.java:241)
  
   There is a layout_width attribute, so what's wrong? I've tried putting
   only one of those views inside of a layout file, and even if the
   Eclipse Android project doesn't complain, the emulator does.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Date and time pickers in an XML layout file - how to get to work?

2008-04-08 Thread Dan U.

I put those within a LinearLayout and it worked fine. Can you post
more of your layout and/or code?

On a side note, I notice DatePicker likes to throw null pointers
during onKey.

On Apr 8, 2:17 pm, NTR [EMAIL PROTECTED] wrote:
 I've tried including date and time pickers in the XML file, like the
 following:

 DatePicker
 xmlns:android=http://schemas.android.com/apk/res/android;
 android:layout_width=wrap_content
 android:layout_height=wrap_content
 /

 TimePicker
 android:id=@+id/wtb_event_time
 android:layout_width=wrap_content
 android:layout_height=wrap_content
 /

 But I get:

 ERROR/AndroidRuntime(2930): Caused by: java.lang.RuntimeException:
 Binary XML file line #40: You must supply a layout_width attribute.
 ERROR/AndroidRuntime(2930): at android.content.Resources
 $StyledAttributes.getLayoutDimension(Resources.java:1247)
 ERROR/AndroidRuntime(2930): at android.view.ViewGroup
 $LayoutParams.setBaseAttributes(ViewGroup.java:2641)
 ERROR/AndroidRuntime(2930): at android.view.ViewGroup
 $LayoutParams.init(ViewGroup.java:2605)
 ERROR/AndroidRuntime(2930): at
 android.view.ViewGroup.generateLayoutParams(ViewGroup.java:2101)
 ERROR/AndroidRuntime(2930): at
 android.view.ViewInflate.inflate(ViewInflate.java:358)
 ERROR/AndroidRuntime(2930): at
 android.view.ViewInflate.inflate(ViewInflate.java:292)
 ERROR/AndroidRuntime(2930): at
 android.view.ViewInflate.inflate(ViewInflate.java:241)

 There is a layout_width attribute, so what's wrong? I've tried putting
 only one of those views inside of a layout file, and even if the
 Eclipse Android project doesn't complain, the emulator does.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---