teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

1

ソースコードを記載

2021/11/24 11:38

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -9,12 +9,24 @@
9
9
  @Override
10
10
  public void onClick(View v){
11
11
 
12
- *****
13
-         時間取得
14
-         時間保存
15
-         別画面に表示
12
+ sample();
16
-         ******
17
13
 
18
14
  }
19
15
 
20
- });
16
+ });
17
+
18
+ public void sample(){
19
+ Calendar cal=Calendar.getInstance();
20
+ String tmp=cal.get(Calendar.YEAR)+"/"+(cal.get(Calendar.MONTH)+1)+"/"+cal.get(Calendar.DATE)+" "+cal.get(Calendar.HOUR_OF_DAY)+":"+cal.get(Calendar.MINUTE);
21
+ printString(tmp);
22
+ }
23
+ public void printString(String s){
24
+ LinearLayout parent=(LinearLayout) findViewById( R.id.parent );
25
+ TextView tv=new TextView( this );
26
+ tv.setTypeface( Typeface.MONOSPACE );
27
+ tv.setText( s );
28
+ parent.addView(tv);
29
+ }
30
+
31
+
32
+ これでやったんですが,これだと保存ができなくて他画面の表示ができなくて困っています。