Advertisement
abbyrockss

Untitled

May 22nd, 2014
706
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.75 KB | None | 0 0
  1. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  2. xmlns:tools="http://schemas.android.com/tools"
  3. android:layout_width="match_parent"
  4. android:layout_height="match_parent"
  5. android:paddingBottom="@dimen/activity_vertical_margin"
  6. android:paddingLeft="@dimen/activity_horizontal_margin"
  7. android:paddingRight="@dimen/activity_horizontal_margin"
  8. android:paddingTop="@dimen/activity_vertical_margin"
  9. tools:context=".MainActivity" >
  10.  
  11. <TextView
  12. android:id="@+id/tv1"
  13. android:layout_width="wrap_content"
  14. android:layout_height="wrap_content"
  15. android:textSize="20dp"
  16. android:layout_centerHorizontal="true"
  17. android:layout_marginTop="50dp"
  18. android:text="aa"/>
  19.  
  20. <TextView
  21. android:id="@+id/tv3"
  22. android:layout_width="wrap_content"
  23. android:layout_height="wrap_content"
  24. android:layout_alignLeft="@+id/tv2"
  25. android:layout_below="@+id/tv2"
  26. android:layout_marginTop="40dp"
  27. android:text="cc"
  28. android:textSize="20dp" />
  29.  
  30. <TextView
  31. android:id="@+id/tv2"
  32. android:layout_width="wrap_content"
  33. android:layout_height="wrap_content"
  34. android:layout_alignLeft="@+id/tv1"
  35. android:layout_below="@+id/tv1"
  36. android:layout_marginTop="48dp"
  37. android:text="bb"
  38. android:textSize="20dp" />
  39.  
  40. <TextView
  41. android:id="@+id/tv4"
  42. android:layout_width="wrap_content"
  43. android:layout_height="wrap_content"
  44. android:layout_alignRight="@+id/tv3"
  45. android:layout_below="@+id/tv3"
  46. android:layout_marginTop="38dp"
  47. android:text="dd"
  48. android:textSize="20dp" />
  49.  
  50. </RelativeLayout>
  51.  
  52.  
  53.  
  54.  
  55.  
  56. public class MainActivity extends Activity {
  57.  
  58. TextView textViewDay, textViewMonth, textViewYear, textViewTime;
  59.  
  60. @Override
  61. protected void onCreate(Bundle savedInstanceState) {
  62. super.onCreate(savedInstanceState);
  63. setContentView(R.layout.activity_main);
  64. textViewDay = (TextView) findViewById(R.id.tv1);
  65. textViewMonth = (TextView) findViewById(R.id.tv2);
  66. textViewYear = (TextView) findViewById(R.id.tv3);
  67. textViewTime = (TextView) findViewById(R.id.tv4);
  68. Time today = new Time(Time.getCurrentTimezone());
  69. today.setToNow();
  70. textViewDay.setText("Date " + today.monthDay + "");
  71. textViewMonth.setText("Month " + today.month + ""); // Month (0-11)
  72. textViewYear.setText("Year " + today.year + ""); // Year
  73. textViewTime.setText("Time " + today.format("%k:%M:%S"));
  74. }
  75.  
  76. @Override
  77. public boolean onCreateOptionsMenu(Menu menu) {
  78. // Inflate the menu; this adds items to the action bar if it is present.
  79. getMenuInflater().inflate(R.menu.main, menu);
  80. return true;
  81. }
  82.  
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement