0

画像があり、別のクラスで使用したいです。だから私はそのようなURIを作成します:

final Uri selectedImage = data.getData();
String path = selectedImage.getPath();
Intent sintent = new Intent(FromFile.this, OurView.class);
sintent.putExtra("image", path);
startActivity(sintent);

OurView のクラスでそのように uri を呼び出しました

String ur = getIntent().getStringExtra("image");
try {
    URI uri = new URI(ur);
} catch (URISyntaxException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}

この写真をこのクラスの背景として使いたいです。どうやってやるの?

4

2 に答える 2

0

Androidには、アクティビティがあります。画像をアクティビティの背景として設定したいようです。これを行うには、親レイアウトの背景として設定する必要があります。

于 2012-07-24T10:01:00.657 に答える
0

パスを渡すのではなく、URI をインテントに直接渡すことができます。putExtra で Parceable Value として取得されます

final Uri selectedImage = data.getData();
Intent sintent = new Intent(FromFile.this, OurView.class);
sintent.putExtra("image", selectedImage);
startActivity(sintent);

その後

URI ur = getIntent().getStringExtra("image");
于 2012-07-24T10:04:34.463 に答える