質問編集履歴
5
String item = \(String\) listView\.getItemAtPosition\(position\);の追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -29,6 +29,7 @@
|
|
29
29
|
教えていただけないでしょうか?
|
30
30
|
|
31
31
|
```java
|
32
|
+
String item =(String)listView.getItemAtPosition(position);
|
32
33
|
String dataand = item.replaceFirst(" ",":");
|
33
34
|
System.out.println("dataand "+dataand);
|
34
35
|
|
4
コードのついか
title
CHANGED
File without changes
|
body
CHANGED
@@ -7,6 +7,7 @@
|
|
7
7
|
|
8
8
|
|
9
9
|
```
|
10
|
+
//なぜ、改行が混じったのかはわかりませんが、このような過程の中で、問題は発生しました。やろうとしてたことを、簡単にいうと、ListViewをCLickして取得したitemを、分別して、データベースのwhere句に指定して、selectしようとしてました。そして、無事、selectまでできました。
|
10
11
|
```java
|
11
12
|
|
12
13
|
//一方違う変数の、usernameですと、printlnを使っても下記のように改行されることはありませんでした。
|
@@ -25,4 +26,52 @@
|
|
25
26
|
```
|
26
27
|
|
27
28
|
javaで、このように改行されて表示されてしまいます。何が原因なのでしょうか?
|
28
|
-
教えていただけないでしょうか?
|
29
|
+
教えていただけないでしょうか?
|
30
|
+
|
31
|
+
```java
|
32
|
+
String dataand = item.replaceFirst(" ",":");
|
33
|
+
System.out.println("dataand "+dataand);
|
34
|
+
|
35
|
+
//最初のスペース(username)までの間を取得して、dataにセット
|
36
|
+
updatedata=dataand.substring(0, dataand.indexOf(" "));
|
37
|
+
System.out.println("data "+updatedata);
|
38
|
+
|
39
|
+
//usernameの判定
|
40
|
+
//" "を削除したdataandから1つめの" "から後ろを取り出す
|
41
|
+
String usernameand =dataand.substring(dataand.indexOf(" ")+1);
|
42
|
+
|
43
|
+
System.out.println("usernameand "+usernameand);
|
44
|
+
//そして、" "より前を取り出す
|
45
|
+
updatetouchusername=usernameand.substring(0, usernameand.indexOf(" "));
|
46
|
+
System.out.println(updatetouchusername+" touchusername");
|
47
|
+
|
48
|
+
|
49
|
+
//comment
|
50
|
+
//usernameandの" "より後ろを取り出す
|
51
|
+
updatecomment=usernameand.substring(usernameand.indexOf(" ")+1);
|
52
|
+
//" "を削除した
|
53
|
+
updatecomment = updatecomment.replaceFirst(" ","");
|
54
|
+
// 改行を削除して解決
|
55
|
+
updatecomment = updatecomment.replaceFirst("\\n","");
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
05-10 19:27:30.122 30834-30834/com.example.sample.near I/System.out: 5/10 1:19 endo いえーい
|
60
|
+
05-10 19:27:30.122 30834-30834/com.example.sample.near I/System.out: 1
|
61
|
+
05-10 19:27:30.122 30834-30834/com.example.sample.near I/System.out: 5/10 1 1.5
|
62
|
+
05-10 19:27:30.122 30834-30834/com.example.sample.near I/System.out: getusedesdata2 null
|
63
|
+
05-10 19:27:30.122 30834-30834/com.example.sample.near I/System.out: timeage null
|
64
|
+
05-10 19:27:30.122 30834-30834/com.example.sample.near I/System.out: 3
|
65
|
+
05-10 19:27:30.122 30834-30834/com.example.sample.near I/System.out: 4
|
66
|
+
05-10 19:27:30.132 30834-30834/com.example.sample.near I/System.out: dataand 5/10:1:19 endo いえーい
|
67
|
+
05-10 19:27:30.132 30834-30834/com.example.sample.near I/System.out: data 5/10:1:19
|
68
|
+
05-10 19:27:30.132 30834-30834/com.example.sample.near I/System.out: usernameand endo いえーい
|
69
|
+
05-10 19:27:30.132 30834-30834/com.example.sample.near I/System.out: endo touchusername
|
70
|
+
05-10 19:27:30.132 30834-30834/com.example.sample.near I/System.out: あああいえーい
|
71
|
+
05-10 19:27:30.132 30834-30834/com.example.sample.near I/System.out: いえーい
|
72
|
+
05-10 19:27:30.132 30834-30834/com.example.sample.near I/System.out: comment:いえーい:
|
73
|
+
05-10 19:27:30.132 30834-30834/com.example.sample.near I/System.out: endoあ:endo
|
74
|
+
05-10 19:27:30.132 30834-30834/com.example.sample.near I/System.out: endo:endo:
|
75
|
+
05-10 19:27:30.132 30834-30834/com.example.sample.near I/System.out: endo:endo
|
76
|
+
05-10 19:27:30.132 30834-30834/com.example.sample.near I/System.out: 5
|
77
|
+
```
|
3
ずれの修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -10,7 +10,8 @@
|
|
10
10
|
```java
|
11
11
|
|
12
12
|
//一方違う変数の、usernameですと、printlnを使っても下記のように改行されることはありませんでした。
|
13
|
-
System.out.println(updateusername+":"+username+":");
|
13
|
+
System.out.println(updateusername+":"+username+":");
|
14
|
+
System.out.println(updateusername+":"+username);
|
14
15
|
|
15
16
|
I/System.out: sato:sato:
|
16
17
|
I/System.out: sato:sato
|
2
修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,15 +1,26 @@
|
|
1
1
|
```java
|
2
|
+
//変数updatecommentですと、printを使っても、下記のように改行されてしまいます。
|
2
|
-
System.out.
|
3
|
+
System.out.print("comment:"+updatecomment+":");
|
3
4
|
|
4
|
-
System.out
|
5
|
+
I/System.out: comment: いえーい
|
5
|
-
|
6
|
+
I/System.out: :
|
7
|
+
|
8
|
+
|
6
9
|
```
|
10
|
+
```java
|
7
11
|
|
12
|
+
//一方違う変数の、usernameですと、printlnを使っても下記のように改行されることはありませんでした。
|
13
|
+
System.out.println(updateusername+":"+username+":"); System.out.println(updateusername+":"+username);
|
14
|
+
|
15
|
+
I/System.out: sato:sato:
|
16
|
+
I/System.out: sato:sato
|
17
|
+
```
|
8
18
|
```java
|
19
|
+
//また、変数updatecommentのみを出力するとこのようになります。
|
9
|
-
|
20
|
+
System.out.print(updatecomment);
|
10
|
-
I/System.out: :
|
11
21
|
|
12
22
|
I/System.out: いえーい
|
23
|
+
|
13
24
|
```
|
14
25
|
|
15
26
|
javaで、このように改行されて表示されてしまいます。何が原因なのでしょうか?
|
1
コードの追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,10 +1,15 @@
|
|
1
1
|
```java
|
2
2
|
System.out.println("comment:"+updatecomment+":");
|
3
|
+
|
4
|
+
System.out.println(updatecomment);
|
5
|
+
|
3
6
|
```
|
4
7
|
|
5
8
|
```java
|
6
9
|
I/System.out: comment: いえーい
|
7
10
|
I/System.out: :
|
11
|
+
|
12
|
+
I/System.out: いえーい
|
8
13
|
```
|
9
14
|
|
10
15
|
javaで、このように改行されて表示されてしまいます。何が原因なのでしょうか?
|