Possible Duplicate:
Android: Display Image from SD CARD
Here's my current code:
import android.app.Activity;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.widget.ImageView;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.RadioGroup.LayoutParams;
public class DisplayImageMapActivity extends Activity {
ImageView iv;
private final String FLOOR = "F";
private final String storagePath = Environment.getExternalStorageDirectory() + "/AppH23";
private final String localMapsPath = storagePath + "/localMaps";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
iv=(ImageView)findViewById(R.id.storageimage);
RadioGroup levelRGroup = (RadioGroup) findViewById(R.id.level_rgroup);
int levelSize = 8;
for (int i = 0; i < levelSize; i++) {
RadioButton levelRButton = new RadioButton(this);
if(i==0) {
levelRButton.setText(new StringBuffer(i+1).append(FLOOR).append("(start)"));
} else if (i==7) {
levelRButton.setText(new StringBuffer(i+1).append(FLOOR).append("(end)"));
}
levelRButton.setTag((i+1) + FLOOR);
levelRButton.setLayoutParams(
new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 1));
levelRGroup.addView(levelRButton);
}
levelRGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
public void onCheckedChanged(RadioGroup group, final int checkedId) {
iv.setImageURI(Uri.parse(new StringBuffer(localMapsPath)
.append("/").append(group.findViewById(checkedId).getTag()).append(".gif").toString()));
iv.invalidate();
}
});
levelRGroup.getChildAt(0).performClick();
}
}
Here's my environment: a) 2.1-update1
It kinda strange, my image from /sdcard/AppH23/localMaps/???.gif doesn't show. all gif files are confirmed that are existing.
UPDATE: here's my previous post and you may confirm that the gif image was displayed a while ago. gif image displayed