gpt4 book ai didi

java - 下一张图片在 'ImageSwitcher' 中滑动时未显示

转载 作者:太空宇宙 更新时间:2023-11-04 11:12:08 25 4
gpt4 key购买 nike

我对 Android 开发非常陌生,我一直在尝试创建一个图片库应用程序。一切工作正常,除了当我滑动以显示下一个或上一个图像时,没有显示任何内容。我该如何解决这个问题?

public class PhotosActivity extends AppCompatActivity {
int int_position;
private GridView gridView;
GridViewAdapter adapter;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_image_gallery);
gridView = (GridView)findViewById(R.id.gv_folder);
int_position = getIntent().getIntExtra("value", 0);
adapter = new GridViewAdapter(this, al_images,int_position);
gridView.setAdapter(adapter);

gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
String abc = "file://" + al_images.get(int_position).getAl_imagepath().get(position);

Intent i = new Intent(getApplicationContext(), FullImageActivity.class);
i.putExtra("id", position);
i.putExtra("abc",abc);
startActivity(i);
}
});
}
}

最佳答案

当我运行你的代码时,我得到了 Nullpointerexeption 。所以我用了

  try {
Intent i = getIntent();

// Selected image id
position = i.getExtras().getInt("id");
Bundle extras = getIntent().getExtras();
String value = extras.getString("abc");

Glide.with(FullImageActivity.this)
.load(value)
.listener(new RequestListener<String, GlideDrawable>() {
@Override
public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
return false; // important to return false so the error placeholder can be placed
}

@Override
public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
return false;
}
})

.into(images);
} catch (NullPointerException n) {
n.printStackTrace();
}

滑动 5 或 6 次后,我可以查看图像。正如您所问的那样,您无法查看图像,所以问题是缩略图不存在。正如在我的日志中,对于每个不可查看的缩略图,我都会收到此错误

I/System.out:resolveUri 在错误的位图 uri 上失败:content://media/external/images/thumbnails/11

希望这可能有所帮助。

ps:WAITING toast 完成,然后再滑动以清除。

关于java - 下一张图片在 'ImageSwitcher' 中滑动时未显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45879314/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com