Alex Mamo
Alex Mamo

Reputation: 138969

What does `I/System.out: -1` mean in Android?

I have created programmatically a RelativeLayout which contains a textView. I'm trying to get the id of the textView using this code:

System.out.println(textView.getId());

When i try to see the result it prints out -1? What does it mean? Thanks!

Upvotes: 0

Views: 681

Answers (1)

Giuly F.
Giuly F.

Reputation: 26

You get I/System.out: -1 because your TextView view not your RelativeLayout as Blackbelt commented, does not have an id.

To get the real id:

  1. Assign in an id first

  2. and then use textView.getId().

Upvotes: 1

Related Questions