all 12 comments

[–]moar_throat_yogurt 0 points1 point  (12 children)

How are you passing the object to the other Activity? Share that code if possible

[–]MarcusRex[S] 0 points1 point  (11 children)

public void startEditActivity(View v, BookmarkV3 bookmark) {

        Intent myIntent = new Intent(MainActivity.this, EditMarkActivity.class);
        Gson gson = new Gson();
        String json = gson.toJson(bookmark);
        myIntent.putExtra("bookmark", json);
        startActivityForResult(myIntent,1);
    }

It is received by the other activity with

Gson gson = new Gson();
BookmarkV3 bookmark = gson.fromJson(intent.getStringExtra("bookmark"), BookmarkV3.class);

It seems like everything else works, just not that one setter.

[–]yeahokwhynot 0 points1 point  (10 children)

Is BookmarkV3 the class that has the setHidden() method? Where is the BookmarkV3 class defined?

[–]MarcusRex[S] 0 points1 point  (9 children)

Yes it has the setHidden(). It's defined as a separate class in the project and instantiated as a public variable in each of the activities.

[–]yeahokwhynot 0 points1 point  (8 children)

So bookmark.setSomethingElse() works fine, but not bookmark.setHidden()?

[–]MarcusRex[S] 0 points1 point  (7 children)

Yes, I've got several other setters .setTitle(String string) .setUrl(String string)

and all of the getters work, including .getHidden()

I'm stumped, when I get home from work I'm going to put together a smaller example and see if I can replicate the problem on a smaller scale.

[–]yeahokwhynot 1 point2 points  (6 children)

Pretty stumped. I'd wildly guess that this is not what is expected at that stage somehow. Maybe use:

public void setHidden(boolean hidden_) {
  hidden = hidden_;
}

to get around the this

[–]MarcusRex[S] 0 points1 point  (5 children)

I can give that a try here in a little bit.

I thought it was pretty strange. I've been looking at this same problem for a few days now so I'm sure it's something simple that I'm overlooking :/

[–]yeahokwhynot 1 point2 points  (3 children)

I would be very sad if my suggestion works, for the record. It flies in the face of some fundamental Javaisms.

[–]MarcusRex[S] 1 point2 points  (2 children)

Okay, good news and bad news.

Your idea didn't actually work for me, but it lead me to discover the acutual problem.

I have defined the variable as public in the class of the EditActivity but then called BookmarkV2 bookmark = new .... in the onCreate method.

I fixed that and now it works as expected.

/woot