- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我更改了类接口(interface)以使用 Parcelable,因为我需要通过一些 Activity 传递对象来完成工作。
所以我已经实现了一个可包裹类(使用一个可以实现这一点的插件),如下所示:
public class Photo implements Parcelable {
private int id;
private Uri image;
private byte[] cropedImage;
private String path;
private Double lat;
private Double lon;
private Double alt;
private String time;
public Photo() {
}
@Override
public int describeContents() {
return 0;
}
public Photo(Uri image, Double lat, Double lon, Double alt, String time) {
this.image = image;
this.lat = lat;
this.lon = lon;
this.alt = alt;
this.time = time;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(this.id);
dest.writeParcelable(this.image, flags);
dest.writeByteArray(this.cropedImage);
dest.writeString(this.path);
dest.writeValue(this.lat);
dest.writeValue(this.lon);
dest.writeValue(this.alt);
dest.writeString(this.time);
}
protected Photo(Parcel in) {
this.id = in.readInt();
this.image = in.readParcelable(Uri.class.getClassLoader());
this.cropedImage = in.createByteArray();
this.path = in.readString();
this.lat = (Double) in.readValue(Double.class.getClassLoader());
this.lon = (Double) in.readValue(Double.class.getClassLoader());
this.alt = (Double) in.readValue(Double.class.getClassLoader());
this.time = in.readString();
}
public static final Creator<Photo> CREATOR = new Creator<Photo>() {
@Override
public Photo createFromParcel(Parcel source) {
return new Photo(source);
}
@Override
public Photo[] newArray(int size) {
return new Photo[size];
}
};
}
在我的 Activity 中,我创建并填充我的照片的构造函数,如下所示:
Photo photo = new Photo(image,location.getLatitude(),location.getLongitude(),location.getAltitude(),data);
Intent i = new Intent(CameraCapture.this, CropImage.class);
i.putExtra("Photo",photo);
我将它传递给 CropImage Activity ,在该 Activity 中我需要检索可包裹并获取特定数据(在本例中只是 uri)
这就是我所做的:
photo = getIntent().getExtras().getParcelable("Photo");
uri = photo.getImage();
getImage() 不存在,我不知道如何检索特定照片对象的可分割字段,有帮助吗?还有其他方法可以使用我不知道的 Parcelable 来做到这一点吗?
非常感谢
最佳答案
正如我所见,您的数据类没有 getter 和 setter ,因此请尝试右键单击该类并选择 create setter 和 getters 。然后使用这些 getter 来获取您的数据
例如。如果你想有时间
private String time;
public String getTime(){
return time;
}
关于java - 通过可分割的槽 Activity 获取特定领域,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44828280/
我在使用 Java 反射获取类中的字段时遇到问题: public class CraftLib { static List alloyRecipes = new ArrayList();
我试图避免此类 ContentDomain 成为上帝类,并将功能隔离到特定类中(以遵循 SRP),就像这样 内容域: public class ContentDomain : IContentDom
1. 什么是领域 百度百科对领域的解释: 领域具体指一种特定的范围或区域 领域一般指的是业务的问题域,领域是有边界的,边界内,规定了我们要做什么,要做的范围,软件项目从开始到交付的过
我有一个包含产品的elasticsearch索引,我试图创建一个具有文本字段功能的搜索列表产品。 数据集的排序示例{"name": "foo", "count": 10}{"name": "bar",
我知道有人问过类似的问题,但我还没有找到明确的解决方案。我正在尝试从一个大类(class)中模拟一个私有(private)领域。私有(private)字段在一些较早的方法中被实例化,我正在尝试对引用该
当使用 JDBC 领域进行授权时,我通常有以下表: 用户表 角色表 分组表 当我现在使用用户名、密码登录时,安全模块会在表中进行查找:为我提供用户的所有角色:用户名。 我可以以某种方式连接到进程并添加
我有两组 Web 应用程序,它们都在同一台 Tomcat 5.5 服务器上运行。 我在 server.xml 中定义了一个通用领域: 我的“美国”应用程序都希望与该数据源共享
我设法使用 key 表在我的 Web 应用程序中启用 SSO。我必须更新以下文件才能使其正常工作: Jass.conf Krb5.conf Server.xml(领域) 网络.xml 它工作正常。我的
我有一个这样定义的结构 private struct Combinators { public const char DirectChild = '>'; public const c
我正在使用 maven 和 eclipse juno 为 Tomcat 7 开发自定义领域。 它看起来很像 Implement a Tomcat Realm with LDAP authenticat
我真的是模拟的新手,正在尝试用模拟对象替换私有(private)字段。目前私有(private)字段的实例是在构造函数中创建的。我的代码看起来像... public class Cache {
在 ECMAScript 规范中引入了“领域”的概念: Before it is evaluated, all ECMAScript code must be associated with a re
我正在为 Subversion 编写一个简单的内部前端。多亏了 WebDAV,我们有一个 Apache 设置为 SVN 存储库提供服务。此外,身份验证是通过 Apache 领域和 Open Direc
有时,C++ 的隐私概念让我感到困惑 :-) class Foo { struct Bar; Bar* p; public: Bar* operator->() const
我现在为此进行了一些搜索,但无法确定 protobuf-net 或 protobuf 通常是否支持以下意义上的前向兼容性: 旧版本的对象使用新字段反序列化新版本的对象,但在将其序列化回时保留该字段,因
根据Nexus 3.x docx,“您还需要启用 Realm 中通常概述的Docker Bearer token Realm 。默认情况下,此 Realm 处于非 Activity 状态” 有人知道如
我正在摆弄 Shiro 安全框架并实现自定义 JDBC 领域。 以下值当前在我的 shiro.ini 文件中设置 jdbcRealm.authenticationQuery = SELECT pass
我有以下 Spring 安全配置类,用于两个独立的安全领域:管理区域和前端区域: @Configuration @EnableWebSecurity @EnableGlobalMethodSecuri
按照目前的情况,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the
我有 posqtresql 数据库。表中有一个整数字段。如何使它只有积极的?不在 rails 中进行验证。我需要在迁移文件中制作它 最佳答案 您可以在 Postgresql 中使用检查约束。 Rail
我是一名优秀的程序员,十分优秀!