在我的应用程序中,我想从中选择图像Gallery并设置图像ListView.在我的ListView I have 16 rows. So when ever item click inListView open the gallery and set the image toListView中,. But my problem is some times afterstartActivityForResult(),oncreate()`方法被调用.这是onclick代码
Intent intent = new Intent(
Intent.ACTION_PICK,
android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
intent.setType("image/*");
startActivityForResult(
Intent.createChooser(intent, "Select File"),
SELECT_PICTURE);
Run Code Online (Sandbox Code Playgroud)
这是一个非常活跃的结果
public void onActivityResult(int requestcode, int resultcode, Intent data) {
Log.e("result", "result");
displayMetrics = this.getResources().getDisplayMetrics();
Ew = displayMetrics.widthPixels;
Eh = displayMetrics.heightPixels;
switch (requestcode) {
case SELECT_PICTURE:
if (resultcode == RESULT_OK) { …Run Code Online (Sandbox Code Playgroud)