質問編集履歴

5

String item = \(String\) listView\.getItemAtPosition\(position\);の追加

2017/05/11 03:34

投稿

edoooooo
edoooooo

スコア476

test CHANGED
File without changes
test CHANGED
@@ -59,6 +59,8 @@
59
59
 
60
60
 
61
61
  ```java
62
+
63
+ String item =(String)listView.getItemAtPosition(position);
62
64
 
63
65
  String dataand = item.replaceFirst(" ",":");
64
66
 

4

コードのついか

2017/05/11 03:34

投稿

edoooooo
edoooooo

スコア476

test CHANGED
File without changes
test CHANGED
@@ -15,6 +15,8 @@
15
15
 
16
16
 
17
17
  ```
18
+
19
+ //なぜ、改行が混じったのかはわかりませんが、このような過程の中で、問題は発生しました。やろうとしてたことを、簡単にいうと、ListViewをCLickして取得したitemを、分別して、データベースのwhere句に指定して、selectしようとしてました。そして、無事、selectまでできました。
18
20
 
19
21
  ```java
20
22
 
@@ -53,3 +55,99 @@
53
55
  javaで、このように改行されて表示されてしまいます。何が原因なのでしょうか?
54
56
 
55
57
  教えていただけないでしょうか?
58
+
59
+
60
+
61
+ ```java
62
+
63
+ String dataand = item.replaceFirst(" ",":");
64
+
65
+ System.out.println("dataand "+dataand);
66
+
67
+
68
+
69
+ //最初のスペース(username)までの間を取得して、dataにセット
70
+
71
+ updatedata=dataand.substring(0, dataand.indexOf(" "));
72
+
73
+ System.out.println("data "+updatedata);
74
+
75
+
76
+
77
+ //usernameの判定
78
+
79
+ //" "を削除したdataandから1つめの" "から後ろを取り出す
80
+
81
+ String usernameand =dataand.substring(dataand.indexOf(" ")+1);
82
+
83
+
84
+
85
+ System.out.println("usernameand "+usernameand);
86
+
87
+ //そして、" "より前を取り出す
88
+
89
+ updatetouchusername=usernameand.substring(0, usernameand.indexOf(" "));
90
+
91
+ System.out.println(updatetouchusername+" touchusername");
92
+
93
+
94
+
95
+
96
+
97
+ //comment
98
+
99
+ //usernameandの" "より後ろを取り出す
100
+
101
+ updatecomment=usernameand.substring(usernameand.indexOf(" ")+1);
102
+
103
+ //" "を削除した
104
+
105
+ updatecomment = updatecomment.replaceFirst(" ","");
106
+
107
+ // 改行を削除して解決
108
+
109
+ updatecomment = updatecomment.replaceFirst("\\n","");
110
+
111
+
112
+
113
+
114
+
115
+
116
+
117
+ 05-10 19:27:30.122 30834-30834/com.example.sample.near I/System.out: 5/10 1:19 endo いえーい
118
+
119
+ 05-10 19:27:30.122 30834-30834/com.example.sample.near I/System.out: 1
120
+
121
+ 05-10 19:27:30.122 30834-30834/com.example.sample.near I/System.out: 5/10 1 1.5
122
+
123
+ 05-10 19:27:30.122 30834-30834/com.example.sample.near I/System.out: getusedesdata2 null
124
+
125
+ 05-10 19:27:30.122 30834-30834/com.example.sample.near I/System.out: timeage null
126
+
127
+ 05-10 19:27:30.122 30834-30834/com.example.sample.near I/System.out: 3
128
+
129
+ 05-10 19:27:30.122 30834-30834/com.example.sample.near I/System.out: 4
130
+
131
+ 05-10 19:27:30.132 30834-30834/com.example.sample.near I/System.out: dataand 5/10:1:19 endo いえーい
132
+
133
+ 05-10 19:27:30.132 30834-30834/com.example.sample.near I/System.out: data 5/10:1:19
134
+
135
+ 05-10 19:27:30.132 30834-30834/com.example.sample.near I/System.out: usernameand endo いえーい
136
+
137
+ 05-10 19:27:30.132 30834-30834/com.example.sample.near I/System.out: endo touchusername
138
+
139
+ 05-10 19:27:30.132 30834-30834/com.example.sample.near I/System.out: あああいえーい
140
+
141
+ 05-10 19:27:30.132 30834-30834/com.example.sample.near I/System.out: いえーい
142
+
143
+ 05-10 19:27:30.132 30834-30834/com.example.sample.near I/System.out: comment:いえーい:
144
+
145
+ 05-10 19:27:30.132 30834-30834/com.example.sample.near I/System.out: endoあ:endo
146
+
147
+ 05-10 19:27:30.132 30834-30834/com.example.sample.near I/System.out: endo:endo:
148
+
149
+ 05-10 19:27:30.132 30834-30834/com.example.sample.near I/System.out: endo:endo
150
+
151
+ 05-10 19:27:30.132 30834-30834/com.example.sample.near I/System.out: 5
152
+
153
+ ```

3

ずれの修正

2017/05/10 10:42

投稿

edoooooo
edoooooo

スコア476

test CHANGED
File without changes
test CHANGED
@@ -22,7 +22,9 @@
22
22
 
23
23
  //一方違う変数の、usernameですと、printlnを使っても下記のように改行されることはありませんでした。
24
24
 
25
- System.out.println(updateusername+":"+username+":"); System.out.println(updateusername+":"+username);
25
+ System.out.println(updateusername+":"+username+":");
26
+
27
+ System.out.println(updateusername+":"+username);
26
28
 
27
29
 
28
30
 

2

修正

2017/05/10 10:09

投稿

edoooooo
edoooooo

スコア476

test CHANGED
File without changes
test CHANGED
@@ -1,18 +1,10 @@
1
1
  ```java
2
2
 
3
+ //変数updatecommentですと、printを使っても、下記のように改行されてしまいます。
4
+
3
- System.out.println("comment:"+updatecomment+":");
5
+ System.out.print("comment:"+updatecomment+":");
4
6
 
5
7
 
6
-
7
- System.out.println(updatecomment);
8
-
9
-
10
-
11
- ```
12
-
13
-
14
-
15
- ```java
16
8
 
17
9
  I/System.out: comment: いえーい
18
10
 
@@ -20,7 +12,37 @@
20
12
 
21
13
 
22
14
 
15
+
16
+
17
+ ```
18
+
19
+ ```java
20
+
21
+
22
+
23
+ //一方違う変数の、usernameですと、printlnを使っても下記のように改行されることはありませんでした。
24
+
25
+ System.out.println(updateusername+":"+username+":"); System.out.println(updateusername+":"+username);
26
+
27
+
28
+
29
+ I/System.out: sato:sato:
30
+
31
+ I/System.out: sato:sato
32
+
33
+ ```
34
+
35
+ ```java
36
+
37
+ //また、変数updatecommentのみを出力するとこのようになります。
38
+
39
+ System.out.print(updatecomment);
40
+
41
+
42
+
23
43
  I/System.out: いえーい
44
+
45
+
24
46
 
25
47
  ```
26
48
 

1

コードの追加

2017/05/10 10:03

投稿

edoooooo
edoooooo

スコア476

test CHANGED
File without changes
test CHANGED
@@ -1,6 +1,12 @@
1
1
  ```java
2
2
 
3
3
  System.out.println("comment:"+updatecomment+":");
4
+
5
+
6
+
7
+ System.out.println(updatecomment);
8
+
9
+
4
10
 
5
11
  ```
6
12
 
@@ -12,6 +18,10 @@
12
18
 
13
19
  I/System.out: :
14
20
 
21
+
22
+
23
+ I/System.out: いえーい
24
+
15
25
  ```
16
26
 
17
27