質問編集履歴

3

ソースコードの更新

2018/02/02 16:19

投稿

hum
hum

スコア12

test CHANGED
File without changes
test CHANGED
@@ -134,7 +134,7 @@
134
134
 
135
135
  pfDescriptor.close();
136
136
 
137
- imageView.setImageBitmap(bmp2);
137
+ ((ImageView) findViewById(R.id.imageView)).setImageBitmap(bmp2);
138
138
 
139
139
  }
140
140
 

2

追記の消去

2018/02/02 16:19

投稿

hum
hum

スコア12

test CHANGED
File without changes
test CHANGED
@@ -15,22 +15,6 @@
15
15
  何方かご教示ください。
16
16
 
17
17
 
18
-
19
- //////////////////追記//////////////////
20
-
21
- アプリケーション自体は起動しました。
22
-
23
- しかし、読み込みボタンを押してギャラリーを開き
24
-
25
- 任意の画像を選択した瞬間に「問題が発生したため・・・」
26
-
27
- とエラーが起きてしまいます。
28
-
29
-
30
-
31
- ソースコードは更新しました。
32
-
33
- たびたび申し訳ありません、ご教示ください。
34
18
 
35
19
 
36
20
 

1

ソースコードの変更

2018/02/02 16:17

投稿

hum
hum

スコア12

test CHANGED
File without changes
test CHANGED
@@ -16,6 +16,24 @@
16
16
 
17
17
 
18
18
 
19
+ //////////////////追記//////////////////
20
+
21
+ アプリケーション自体は起動しました。
22
+
23
+ しかし、読み込みボタンを押してギャラリーを開き
24
+
25
+ 任意の画像を選択した瞬間に「問題が発生したため・・・」
26
+
27
+ とエラーが起きてしまいます。
28
+
29
+
30
+
31
+ ソースコードは更新しました。
32
+
33
+ たびたび申し訳ありません、ご教示ください。
34
+
35
+
36
+
19
37
  以下は問題のソースコードです。
20
38
 
21
39
 
@@ -27,8 +45,6 @@
27
45
 
28
46
 
29
47
  private static final int RESULT_PICK_IMAGEFILE = 1000;
30
-
31
- Button button = findViewById(R.id.button1); //読み込み
32
48
 
33
49
  ImageView imageView;
34
50
 
@@ -44,7 +60,11 @@
44
60
 
45
61
 
46
62
 
63
+ Button button = findViewById(R.id.button1); //読み込み
64
+
65
+
66
+
47
- Bitmap bmp = BitmapFactory.decodeResource(
67
+ Bitmap bmp1 = BitmapFactory.decodeResource(
48
68
 
49
69
  MainActivity.this.getResources(),
50
70
 
@@ -56,13 +76,13 @@
56
76
 
57
77
 
58
78
 
59
- ((ImageView) findViewById(R.id.imageView)).setImageBitmap(bmp);
79
+ ((ImageView) findViewById(R.id.imageView)).setImageBitmap(bmp1);
60
80
 
61
81
 
62
82
 
63
83
 
64
84
 
65
- /////////読み込みボタン//////////
85
+ /////////////読み込みボタン///////////
66
86
 
67
87
  button.setOnClickListener(new View.OnClickListener() {
68
88
 
@@ -78,9 +98,13 @@
78
98
 
79
99
 
80
100
 
101
+ //onActivityResultを起動
102
+
81
103
  startActivityForResult(intent, RESULT_PICK_IMAGEFILE);
82
104
 
83
- imageView.setImageBitmap(bmp);
105
+
106
+
107
+
84
108
 
85
109
 
86
110
 
@@ -88,11 +112,15 @@
88
112
 
89
113
  });
90
114
 
91
- }
115
+ /////////////////////////////////////
92
116
 
93
- }
94
117
 
118
+
119
+
120
+
121
+
122
+
95
- ////////////////////////////////
123
+ }
96
124
 
97
125
 
98
126
 
@@ -118,11 +146,11 @@
118
146
 
119
147
  FileDescriptor fileDescriptor = pfDescriptor.getFileDescriptor();
120
148
 
121
- Bitmap bmp = BitmapFactory.decodeFileDescriptor(fileDescriptor);
149
+ Bitmap bmp2 = BitmapFactory.decodeFileDescriptor(fileDescriptor);
122
150
 
123
151
  pfDescriptor.close();
124
152
 
125
- imageView.setImageBitmap(bmp);
153
+ imageView.setImageBitmap(bmp2);
126
154
 
127
155
  }
128
156