質問編集履歴
4
エラーメッセージの修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -5,7 +5,54 @@
|
|
5
5
|
###発生している問題・エラーメッセージ
|
6
6
|
|
7
7
|
```
|
8
|
+
E/AndroidRuntime: FATAL EXCEPTION: main
|
9
|
+
Process: com.example.innovation.f_featnote, PID: 2899
|
8
|
-
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.Object.toString()' on a null object reference
|
10
|
+
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.Object.toString()' on a null object reference
|
11
|
+
at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:394)
|
12
|
+
at android.widget.ArrayAdapter.getView(ArrayAdapter.java:362)
|
13
|
+
at android.widget.AbsListView.obtainView(AbsListView.java:2344)
|
14
|
+
at android.widget.ListView.makeAndAddView(ListView.java:1864)
|
15
|
+
at android.widget.ListView.fillDown(ListView.java:698)
|
16
|
+
at android.widget.ListView.fillFromTop(ListView.java:759)
|
17
|
+
at android.widget.ListView.layoutChildren(ListView.java:1673)
|
18
|
+
at android.widget.AbsListView.onLayout(AbsListView.java:2148)
|
19
|
+
at android.view.View.layout(View.java:15596)
|
20
|
+
at android.view.ViewGroup.layout(ViewGroup.java:4966)
|
21
|
+
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1703)
|
22
|
+
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1557)
|
23
|
+
at android.widget.LinearLayout.onLayout(LinearLayout.java:1466)
|
24
|
+
at android.view.View.layout(View.java:15596)
|
25
|
+
at android.view.ViewGroup.layout(ViewGroup.java:4966)
|
26
|
+
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:573)
|
27
|
+
at android.widget.FrameLayout.onLayout(FrameLayout.java:508)
|
28
|
+
at android.view.View.layout(View.java:15596)
|
29
|
+
at android.view.ViewGroup.layout(ViewGroup.java:4966)
|
30
|
+
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1703)
|
31
|
+
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1557)
|
32
|
+
at android.widget.LinearLayout.onLayout(LinearLayout.java:1466)
|
33
|
+
at android.view.View.layout(View.java:15596)
|
34
|
+
at android.view.ViewGroup.layout(ViewGroup.java:4966)
|
35
|
+
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:573)
|
36
|
+
at android.widget.FrameLayout.onLayout(FrameLayout.java:508)
|
37
|
+
at android.view.View.layout(View.java:15596)
|
38
|
+
at android.view.ViewGroup.layout(ViewGroup.java:4966)
|
39
|
+
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2072)
|
40
|
+
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1829)
|
41
|
+
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1054)
|
42
|
+
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5779)
|
43
|
+
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767)
|
44
|
+
at android.view.Choreographer.doCallbacks(Choreographer.java:580)
|
45
|
+
at android.view.Choreographer.doFrame(Choreographer.java:550)
|
46
|
+
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753)
|
47
|
+
at android.os.Handler.handleCallback(Handler.java:739)
|
48
|
+
at android.os.Handler.dispatchMessage(Handler.java:95)
|
49
|
+
at android.os.Looper.loop(Looper.java:135)
|
50
|
+
at android.app.ActivityThread.main(ActivityThread.java:5221)
|
51
|
+
at java.lang.reflect.Method.invoke(Native Method)
|
52
|
+
at java.lang.reflect.Method.invoke(Method.java:372)
|
53
|
+
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
|
54
|
+
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
|
55
|
+
|
9
56
|
```
|
10
57
|
|
11
58
|
###java
|
3
修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -12,57 +12,92 @@
|
|
12
12
|
```
|
13
13
|
package com.example.innovation.f_featnote;
|
14
14
|
|
15
|
+
|
15
16
|
import android.app.Activity;
|
17
|
+
|
16
18
|
import android.app.ListActivity;
|
19
|
+
|
17
20
|
import android.content.Context;
|
21
|
+
|
18
22
|
import android.content.Intent;
|
23
|
+
|
19
24
|
import android.database.Cursor;
|
25
|
+
|
20
26
|
import android.database.sqlite.SQLiteDatabase;
|
27
|
+
|
21
28
|
import android.database.sqlite.SQLiteException;
|
29
|
+
|
22
30
|
import android.database.sqlite.SQLiteOpenHelper;
|
31
|
+
|
23
32
|
import android.os.Bundle;
|
33
|
+
|
24
34
|
import android.provider.ContactsContract;
|
35
|
+
|
25
36
|
import android.util.Log;
|
37
|
+
|
26
38
|
import android.view.LayoutInflater;
|
39
|
+
|
27
40
|
import android.view.View;
|
41
|
+
|
28
42
|
import android.view.ViewGroup;
|
43
|
+
|
29
44
|
import android.widget.AdapterView;
|
45
|
+
|
30
46
|
import android.widget.ArrayAdapter;
|
47
|
+
|
31
48
|
import android.widget.BaseAdapter;
|
49
|
+
|
32
50
|
import android.widget.Button;
|
51
|
+
|
33
52
|
import android.widget.ListView;
|
53
|
+
|
34
54
|
import android.widget.TextView;
|
55
|
+
|
35
56
|
import android.widget.Toast;
|
36
57
|
|
58
|
+
|
37
59
|
import com.example.innovation.f_featnote.SubOpenHelper;
|
60
|
+
|
38
61
|
import com.example.innovation.f_featnote.MainActivity;
|
39
62
|
|
63
|
+
|
40
64
|
import java.util.ArrayList;
|
65
|
+
|
41
66
|
import java.util.Arrays;
|
67
|
+
|
42
68
|
import java.util.List;
|
43
69
|
|
44
|
-
/**
|
45
|
-
* Created by Innovation on 2017/01/26.
|
46
|
-
*/
|
47
70
|
|
48
71
|
public class SqlLoad extends Activity {
|
72
|
+
|
49
73
|
ListView lv;
|
74
|
+
|
50
75
|
static String[][] list;
|
76
|
+
|
51
77
|
static String[] Did = new String[2];
|
78
|
+
|
52
79
|
static long id_;
|
80
|
+
|
53
81
|
static boolean[] flg;
|
82
|
+
|
54
83
|
static String[] Data;
|
84
|
+
|
55
85
|
private final int WC = ViewGroup.LayoutParams.WRAP_CONTENT;
|
56
86
|
|
87
|
+
|
57
88
|
@Override
|
58
89
|
protected void onCreate(Bundle savedInstanceState) {
|
90
|
+
|
59
91
|
super.onCreate(savedInstanceState);
|
92
|
+
|
60
93
|
setContentView(R.layout.sql_load);
|
94
|
+
|
61
95
|
// final boolean[] flg = new boolean[1];
|
62
96
|
|
63
97
|
|
64
98
|
|
65
99
|
|
100
|
+
|
66
101
|
Main();
|
67
102
|
}
|
68
103
|
|
@@ -70,25 +105,42 @@
|
|
70
105
|
|
71
106
|
Data = SQLDataGet();
|
72
107
|
// lv = new ListView(this);
|
108
|
+
|
73
109
|
// ArrayList<String> Data = new ArrayList<>(Arrays.asList(SQLDataGet()));
|
110
|
+
|
74
111
|
lv = (ListView)findViewById(R.id.sql_load_main);
|
112
|
+
|
75
|
-
ArrayAdapter<String> adapter = new ArrayAdapter<>(this,
|
113
|
+
ArrayAdapter<String> adapter = new ArrayAdapter<>(this,
|
114
|
+
android.R.layout.simple_expandable_list_item_1, Data);
|
115
|
+
|
76
116
|
lv.setAdapter(adapter);//リスト表示
|
117
|
+
|
77
118
|
// setContentView(lv,new ViewGroup.LayoutParams(WC,WC));
|
78
119
|
|
120
|
+
|
79
121
|
lv.setOnItemClickListener(new AdapterView.OnItemClickListener(){
|
80
122
|
@Override
|
81
123
|
public void onItemClick(AdapterView<?> parent,View view,int position,long id){
|
124
|
+
|
82
125
|
// ListView listView = (ListView) parent;
|
126
|
+
|
83
127
|
// String item = (String)listView.getItemAtPosition(position);
|
128
|
+
|
84
129
|
Log.d("id",""+id);
|
130
|
+
|
85
131
|
id_ = id;
|
86
132
|
SQLDContentGet();
|
133
|
+
|
87
134
|
SQLDataSet();
|
135
|
+
|
88
136
|
finish();
|
137
|
+
|
89
138
|
// Toast.makeText(getApplicationContext(),item + "clicked",Toast.LENGTH_LONG).show();
|
139
|
+
|
90
140
|
}
|
141
|
+
|
91
142
|
});
|
143
|
+
|
92
144
|
}
|
93
145
|
|
94
146
|
|
@@ -96,48 +148,87 @@
|
|
96
148
|
|
97
149
|
|
98
150
|
public String[] SQLDataGet(){
|
151
|
+
|
99
152
|
MainActivity main = new MainActivity();
|
153
|
+
|
100
154
|
Context con = this;
|
155
|
+
|
101
156
|
List ls = null;
|
157
|
+
|
102
158
|
SQLiteDatabase sdb = main.SQLopen(con.getApplicationContext());//MainActivity参照
|
159
|
+
|
103
160
|
final String[] columns = new String[]{"title","content","date"};//列名
|
161
|
+
|
104
162
|
String where = null;//条件
|
163
|
+
|
105
164
|
String[] Args = new String[]{""};//?の置き換え
|
165
|
+
|
106
166
|
Cursor c = sdb.query("MemoContents", columns,where, null, null, null, null);
|
167
|
+
|
107
168
|
int startPostion = c.getPosition();
|
169
|
+
|
108
170
|
c.moveToFirst();
|
171
|
+
|
109
172
|
list = new String[c.getCount()][columns.length];
|
173
|
+
|
110
174
|
String[] Dlist = new String[c.getCount()];
|
175
|
+
|
111
176
|
for (int i = 0; i< list[0].length-1; i++){
|
177
|
+
|
112
178
|
for (int j = 0; j < list[1].length; j++){
|
179
|
+
|
113
180
|
list[i][j] = c.getString(j);
|
181
|
+
|
114
182
|
Log.d(i+"-"+j,list[i][j]);//デバッグ
|
183
|
+
|
115
184
|
Dlist[i] = list[i][0];
|
185
|
+
|
116
186
|
}
|
187
|
+
|
117
188
|
c.moveToNext();
|
189
|
+
|
118
190
|
}
|
191
|
+
|
119
192
|
c.moveToPosition(startPostion);
|
120
193
|
|
121
194
|
// finish();
|
195
|
+
|
122
196
|
return Dlist;
|
123
197
|
}
|
124
198
|
|
125
199
|
public void SQLDContentGet(){
|
200
|
+
|
126
201
|
Did[0] = list[(int)id_][0];
|
202
|
+
|
127
203
|
Did[1] = list[(int)id_][1];
|
204
|
+
|
128
205
|
}
|
129
206
|
|
130
207
|
public void SQLDataSet(){
|
208
|
+
|
131
209
|
Intent data = new Intent();
|
210
|
+
|
132
211
|
Bundle bundle = new Bundle();
|
212
|
+
|
133
213
|
data.putExtra("key.data",Did);
|
214
|
+
|
134
215
|
data.putExtras(bundle);
|
216
|
+
|
217
|
+
|
135
218
|
setResult(RESULT_OK,data);
|
219
|
+
|
136
220
|
finish();
|
221
|
+
|
137
222
|
}
|
138
223
|
|
139
224
|
@Override
|
225
|
+
|
140
226
|
public void finish() {
|
227
|
+
|
141
228
|
super.finish();
|
229
|
+
|
142
230
|
}
|
231
|
+
|
232
|
+
}
|
233
|
+
|
143
|
-
|
234
|
+
```
|
2
微修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -13,129 +13,80 @@
|
|
13
13
|
package com.example.innovation.f_featnote;
|
14
14
|
|
15
15
|
import android.app.Activity;
|
16
|
-
|
17
16
|
import android.app.ListActivity;
|
18
|
-
|
19
17
|
import android.content.Context;
|
20
|
-
|
21
18
|
import android.content.Intent;
|
22
|
-
|
23
19
|
import android.database.Cursor;
|
24
|
-
|
25
20
|
import android.database.sqlite.SQLiteDatabase;
|
26
|
-
|
27
21
|
import android.database.sqlite.SQLiteException;
|
28
|
-
|
29
22
|
import android.database.sqlite.SQLiteOpenHelper;
|
30
|
-
|
31
23
|
import android.os.Bundle;
|
32
|
-
|
33
24
|
import android.provider.ContactsContract;
|
34
|
-
|
35
25
|
import android.util.Log;
|
36
|
-
|
37
26
|
import android.view.LayoutInflater;
|
38
|
-
|
39
27
|
import android.view.View;
|
40
|
-
|
41
28
|
import android.view.ViewGroup;
|
42
|
-
|
43
29
|
import android.widget.AdapterView;
|
44
|
-
|
45
30
|
import android.widget.ArrayAdapter;
|
46
|
-
|
47
31
|
import android.widget.BaseAdapter;
|
48
|
-
|
49
32
|
import android.widget.Button;
|
50
|
-
|
51
33
|
import android.widget.ListView;
|
52
|
-
|
53
34
|
import android.widget.TextView;
|
54
|
-
|
55
35
|
import android.widget.Toast;
|
56
36
|
|
57
37
|
import com.example.innovation.f_featnote.SubOpenHelper;
|
58
|
-
|
59
38
|
import com.example.innovation.f_featnote.MainActivity;
|
60
39
|
|
61
40
|
import java.util.ArrayList;
|
62
|
-
|
63
41
|
import java.util.Arrays;
|
64
|
-
|
65
42
|
import java.util.List;
|
66
43
|
|
44
|
+
/**
|
45
|
+
* Created by Innovation on 2017/01/26.
|
46
|
+
*/
|
47
|
+
|
67
48
|
public class SqlLoad extends Activity {
|
68
|
-
|
69
49
|
ListView lv;
|
70
|
-
|
71
|
-
static String[][] list;
|
50
|
+
static String[][] list;
|
72
|
-
|
73
51
|
static String[] Did = new String[2];
|
74
|
-
|
75
52
|
static long id_;
|
76
|
-
|
77
53
|
static boolean[] flg;
|
78
|
-
|
79
54
|
static String[] Data;
|
80
|
-
|
81
55
|
private final int WC = ViewGroup.LayoutParams.WRAP_CONTENT;
|
82
56
|
|
83
57
|
@Override
|
84
58
|
protected void onCreate(Bundle savedInstanceState) {
|
85
|
-
|
86
59
|
super.onCreate(savedInstanceState);
|
87
|
-
|
88
60
|
setContentView(R.layout.sql_load);
|
61
|
+
// final boolean[] flg = new boolean[1];
|
89
62
|
|
90
|
-
// final boolean[] flg = new boolean[1];
|
91
63
|
|
92
64
|
|
93
65
|
|
94
|
-
|
95
66
|
Main();
|
96
67
|
}
|
97
68
|
|
98
69
|
public void Main(){
|
99
70
|
|
100
71
|
Data = SQLDataGet();
|
101
|
-
|
102
72
|
// lv = new ListView(this);
|
103
|
-
|
104
73
|
// ArrayList<String> Data = new ArrayList<>(Arrays.asList(SQLDataGet()));
|
105
|
-
|
106
74
|
lv = (ListView)findViewById(R.id.sql_load_main);
|
107
|
-
|
108
|
-
ArrayAdapter<String> adapter = new ArrayAdapter<>(this,
|
75
|
+
ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_expandable_list_item_1, Data);
|
109
|
-
|
110
|
-
android.R.layout.simple_expandable_list_item_1, Data);
|
111
|
-
|
112
76
|
lv.setAdapter(adapter);//リスト表示
|
113
|
-
|
114
77
|
// setContentView(lv,new ViewGroup.LayoutParams(WC,WC));
|
115
78
|
|
116
|
-
|
117
79
|
lv.setOnItemClickListener(new AdapterView.OnItemClickListener(){
|
118
|
-
|
119
80
|
@Override
|
120
|
-
|
121
81
|
public void onItemClick(AdapterView<?> parent,View view,int position,long id){
|
122
|
-
|
123
82
|
// ListView listView = (ListView) parent;
|
124
|
-
|
125
83
|
// String item = (String)listView.getItemAtPosition(position);
|
126
|
-
|
127
84
|
Log.d("id",""+id);
|
128
|
-
|
129
85
|
id_ = id;
|
130
|
-
|
131
86
|
SQLDContentGet();
|
132
|
-
|
133
87
|
SQLDataSet();
|
134
|
-
|
135
88
|
finish();
|
136
|
-
|
137
89
|
// Toast.makeText(getApplicationContext(),item + "clicked",Toast.LENGTH_LONG).show();
|
138
|
-
|
139
90
|
}
|
140
91
|
});
|
141
92
|
}
|
@@ -145,87 +96,48 @@
|
|
145
96
|
|
146
97
|
|
147
98
|
public String[] SQLDataGet(){
|
148
|
-
|
149
99
|
MainActivity main = new MainActivity();
|
150
|
-
|
151
100
|
Context con = this;
|
152
|
-
|
153
101
|
List ls = null;
|
154
|
-
|
155
102
|
SQLiteDatabase sdb = main.SQLopen(con.getApplicationContext());//MainActivity参照
|
156
|
-
|
157
103
|
final String[] columns = new String[]{"title","content","date"};//列名
|
158
|
-
|
159
104
|
String where = null;//条件
|
160
|
-
|
161
105
|
String[] Args = new String[]{""};//?の置き換え
|
162
|
-
|
163
106
|
Cursor c = sdb.query("MemoContents", columns,where, null, null, null, null);
|
164
|
-
|
165
107
|
int startPostion = c.getPosition();
|
166
|
-
|
167
108
|
c.moveToFirst();
|
168
|
-
|
169
109
|
list = new String[c.getCount()][columns.length];
|
170
|
-
|
171
110
|
String[] Dlist = new String[c.getCount()];
|
172
|
-
|
173
111
|
for (int i = 0; i< list[0].length-1; i++){
|
174
|
-
|
175
112
|
for (int j = 0; j < list[1].length; j++){
|
176
|
-
|
177
113
|
list[i][j] = c.getString(j);
|
178
|
-
|
179
114
|
Log.d(i+"-"+j,list[i][j]);//デバッグ
|
180
|
-
|
181
115
|
Dlist[i] = list[i][0];
|
182
|
-
|
183
116
|
}
|
184
|
-
|
185
117
|
c.moveToNext();
|
186
|
-
|
187
118
|
}
|
188
|
-
|
189
119
|
c.moveToPosition(startPostion);
|
190
120
|
|
191
121
|
// finish();
|
192
|
-
|
193
122
|
return Dlist;
|
194
|
-
|
195
123
|
}
|
196
124
|
|
197
125
|
public void SQLDContentGet(){
|
198
|
-
|
199
126
|
Did[0] = list[(int)id_][0];
|
200
|
-
|
201
127
|
Did[1] = list[(int)id_][1];
|
202
|
-
|
203
128
|
}
|
204
129
|
|
205
130
|
public void SQLDataSet(){
|
206
|
-
|
207
131
|
Intent data = new Intent();
|
208
|
-
|
209
132
|
Bundle bundle = new Bundle();
|
210
|
-
|
211
133
|
data.putExtra("key.data",Did);
|
212
|
-
|
213
134
|
data.putExtras(bundle);
|
214
|
-
|
215
135
|
setResult(RESULT_OK,data);
|
216
|
-
|
217
136
|
finish();
|
218
|
-
|
219
137
|
}
|
220
138
|
|
221
139
|
@Override
|
222
|
-
|
223
140
|
public void finish() {
|
224
|
-
|
225
141
|
super.finish();
|
226
|
-
|
227
142
|
}
|
228
|
-
|
229
|
-
}
|
230
|
-
|
231
|
-
```
|
143
|
+
}```
|
1
すみません 修正しました
title
CHANGED
File without changes
|
body
CHANGED
@@ -8,7 +8,8 @@
|
|
8
8
|
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.Object.toString()' on a null object reference
|
9
9
|
```
|
10
10
|
|
11
|
-
###
|
11
|
+
###java
|
12
|
+
```
|
12
13
|
package com.example.innovation.f_featnote;
|
13
14
|
|
14
15
|
import android.app.Activity;
|