Eclipseは私のコードのところでClassbodyを完成させるために '}'を挿入する構文エラーを表示し続けますが、そうすると、コードの最後の部分が到達できないという別のエラーが表示されます。何が間違っているのですか?到達不能なコードですか?ユーザー画像のアップロード
マイコード:
public class GetImage extends Activity {
private static final int MyImage =1;
ImageView iv;
@Override
protected void onCreate(Bundle savedInsatnceState){
super.onCreate(savedInsatnceState);
setContentView(R.layout.diary_edit);
iv=(ImageView)findViewById(R.id.imageView1);
}
public void btnClick(View v){
Intent int3 = new Intent(Intent.ACTION_PICK,android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(int3,MyImage);
}
@Override
protected void onActivityResult (int requestCode , int resultCode , Intent data){
super.onActivityResult(requestCode , resultCode , data);
switch (requestCode){
case MyImage :
if(resultCode == RESULT_OK){
Uri uri=data.getData();
String[]projection ={MediaStore.Images.Media.DATA};
Cursor cursor = getContentResolver().query(uri,projection , null,null,null);
cursor.moveToFirst();
int columnIndex=cursor.getColumnIndex(projection[0]);
String filePath=cursor.getString(columnIndex);
cursor.close();
Bitmap yourSelectedImage=BitmapFactory.decodeFile(filePath);
Drawable d=new BitmapDrawable(yourSelectedImage);
iv.setBackground(d);
}
break;
ault:
break;
}
}
あなたの文は閉じ括弧が欠落することが見える場合。 – rmlan