2

我将两个ints 从一个活动传递到另一个活动,作为我自己班级变量的一部分。

问题是这些值应该是 0,0,但它显示了一些随机数,如 126435,4。

我的班级(项目)的结构:

public class item implements Parcelable {
private int id;
private String title;
private String desc;
private double lat;
private double lon;
private String pub;
private int p;
private int n;
//private int cat;

public item(int id, String title, String desc, double lat, double lon, String pub, int p, int n) {
    super();
    this.id = id;
    this.title = title;
    this.desc = desc;
    this.lat = lat;
    this.lon = lon;
    this.pub = pub;
    this.p = p;
    this.n = n;
    //this.cat=cat;
}

放置额外的变量(项目):(我不正确。我已经检查过了,它返回 0,0,因为它是:

Intent.putExtra("thing",markers.get(i));
startActivity(Intent);

但是当它通过并且我SetText用来将它设置为 textView 时,它显示了一些随机数,我不知道它们来自哪里:

positive.setText(item.getP()+"");
negative.setText(item.getN()+"");

然后我从 Intent Extra 中获取项目:

item = getIntent().getParcelableExtra("thing");

日志猫:

08-12 00:08:53.181: D/dalvikvm(5093): GC_CONCURRENT freed 459K, 19% free 12879K/15751K, paused 13ms+6ms, total 58ms
08-12 00:08:53.661: D/ProgressBar(5093): setProgress = 0
08-12 00:08:53.661: D/ProgressBar(5093): setProgress = 0, fromUser = false
08-12 00:08:53.661: D/ProgressBar(5093): mProgress = 0mIndeterminate = false, mMin = 0, mMax = 100
08-12 00:08:53.661: D/ProgressBar(5093): setProgress = 0
08-12 00:08:53.661: D/ProgressBar(5093): setProgress = 0, fromUser = false
08-12 00:08:53.661: D/ProgressBar(5093): mProgress = 0mIndeterminate = false, mMin = 0, mMax = 100
08-12 00:08:53.821: W/SurfaceView(5093): CHECK surface infomation creating=false formatChanged=false sizeChanged=false visible=false visibleChanged=true surfaceChanged=true realSizeChanged=false redrawNeeded=true left=false top=false
08-12 00:08:54.672: D/dalvikvm(5093): GC_FOR_ALLOC freed 1111K, 21% free 12489K/15751K, paused 60ms, total 60ms
08-12 00:08:55.493: I/Async-Example(5093): onPostExecute Called

多谢你们!

4

1 回答 1

3

在我的 Parcelable 实现中,我没有以相同的顺序读写。

于 2013-08-11T21:55:50.617 回答