回答編集履歴

3

追記

2018/04/09 09:12

投稿

glat2238
glat2238

スコア124

test CHANGED
@@ -1,109 +1 @@
1
1
  最初に字幕を表示する時間を全部取得しちゃってタイマー機能で字幕の動きを動画と最初に同期させちゃって後は字幕と動画を同時に再生すれば綺麗に流れると思う
2
-
3
-
4
-
5
- 追記:
6
-
7
-
8
-
9
-
10
-
11
- こんな感じかな(androidたまにしかやらないので間違ってたらすいません。)
12
-
13
- 指定された間隔でテキストをカウントアップするという謎のコード
14
-
15
- ```
16
-
17
- //スレッドUI操作用ハンドラ
18
-
19
- private Handler mHandler = new Handler();
20
-
21
- //テキストオブジェクト
22
-
23
- private Runnable updateText;
24
-
25
- //間隔
26
-
27
- private int[] wait = //ここにまつ間隔を
28
-
29
-
30
-
31
- @Override
32
-
33
- protected void onCreate(Bundle savedInstanceState) {
34
-
35
- super.onCreate(savedInstanceState);
36
-
37
- setContentView(R.layout.activity_main);
38
-
39
- updateText = new Runnable() {
40
-
41
- public void run() {
42
-
43
- TextView text = (TextView) findViewById(R.id.count);
44
-
45
- Integer count = Integer.valueOf(text.getText().toString());
46
-
47
- count += 1;
48
-
49
- text.setText(count.toString());
50
-
51
- mHandler.removeCallbacks(updateText);
52
-
53
- mHandler.postDelayed(updateText, wait[count]);
54
-
55
- }
56
-
57
- };
58
-
59
- mHandler.postDelayed(updateText, wait[0]);
60
-
61
- }
62
-
63
-
64
-
65
- ```
66
-
67
- ```
68
-
69
- <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
70
-
71
- xmlns:tools="http://schemas.android.com/tools"
72
-
73
- android:layout_width="match_parent"
74
-
75
- android:layout_height="match_parent"
76
-
77
- android:paddingBottom="@dimen/activity_vertical_margin"
78
-
79
- android:paddingLeft="@dimen/activity_horizontal_margin"
80
-
81
- android:paddingRight="@dimen/activity_horizontal_margin"
82
-
83
- android:paddingTop="@dimen/activity_vertical_margin"
84
-
85
- tools:context=".MainActivity" >
86
-
87
-
88
-
89
- <TextView
90
-
91
- android:id="@+id/count"
92
-
93
- android:layout_width="wrap_content"
94
-
95
- android:layout_height="wrap_content"
96
-
97
- android:text="0" />
98
-
99
-
100
-
101
- </RelativeLayout>
102
-
103
-
104
-
105
- ```
106
-
107
-
108
-
109
- 参考:https://dev.classmethod.jp/smartphone/android/android-tas/

2

追記

2018/04/09 09:12

投稿

glat2238
glat2238

スコア124

test CHANGED
@@ -1 +1,109 @@
1
1
  最初に字幕を表示する時間を全部取得しちゃってタイマー機能で字幕の動きを動画と最初に同期させちゃって後は字幕と動画を同時に再生すれば綺麗に流れると思う
2
+
3
+
4
+
5
+ 追記:
6
+
7
+
8
+
9
+
10
+
11
+ こんな感じかな(androidたまにしかやらないので間違ってたらすいません。)
12
+
13
+ 指定された間隔でテキストをカウントアップするという謎のコード
14
+
15
+ ```
16
+
17
+ //スレッドUI操作用ハンドラ
18
+
19
+ private Handler mHandler = new Handler();
20
+
21
+ //テキストオブジェクト
22
+
23
+ private Runnable updateText;
24
+
25
+ //間隔
26
+
27
+ private int[] wait = //ここにまつ間隔を
28
+
29
+
30
+
31
+ @Override
32
+
33
+ protected void onCreate(Bundle savedInstanceState) {
34
+
35
+ super.onCreate(savedInstanceState);
36
+
37
+ setContentView(R.layout.activity_main);
38
+
39
+ updateText = new Runnable() {
40
+
41
+ public void run() {
42
+
43
+ TextView text = (TextView) findViewById(R.id.count);
44
+
45
+ Integer count = Integer.valueOf(text.getText().toString());
46
+
47
+ count += 1;
48
+
49
+ text.setText(count.toString());
50
+
51
+ mHandler.removeCallbacks(updateText);
52
+
53
+ mHandler.postDelayed(updateText, wait[count]);
54
+
55
+ }
56
+
57
+ };
58
+
59
+ mHandler.postDelayed(updateText, wait[0]);
60
+
61
+ }
62
+
63
+
64
+
65
+ ```
66
+
67
+ ```
68
+
69
+ <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
70
+
71
+ xmlns:tools="http://schemas.android.com/tools"
72
+
73
+ android:layout_width="match_parent"
74
+
75
+ android:layout_height="match_parent"
76
+
77
+ android:paddingBottom="@dimen/activity_vertical_margin"
78
+
79
+ android:paddingLeft="@dimen/activity_horizontal_margin"
80
+
81
+ android:paddingRight="@dimen/activity_horizontal_margin"
82
+
83
+ android:paddingTop="@dimen/activity_vertical_margin"
84
+
85
+ tools:context=".MainActivity" >
86
+
87
+
88
+
89
+ <TextView
90
+
91
+ android:id="@+id/count"
92
+
93
+ android:layout_width="wrap_content"
94
+
95
+ android:layout_height="wrap_content"
96
+
97
+ android:text="0" />
98
+
99
+
100
+
101
+ </RelativeLayout>
102
+
103
+
104
+
105
+ ```
106
+
107
+
108
+
109
+ 参考:https://dev.classmethod.jp/smartphone/android/android-tas/

1

読みやすさの評価向上

2018/04/09 09:10

投稿

glat2238
glat2238

スコア124

test CHANGED
@@ -1 +1 @@
1
- 最初に字幕を表示する時間を全部取得しちゃってタイマー機能とかを使って字幕を動画と連携しながら再生するんじゃなくて字幕の動きを動画と最初に同期させちゃって後は字幕と動画を同時に再生すれば綺麗に流れると思う
1
+ 最初に字幕を表示する時間を全部取得しちゃってタイマー機能字幕の動きを動画と最初に同期させちゃって後は字幕と動画を同時に再生すれば綺麗に流れると思う