Reputation: 138969
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
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:
Assign in an id first
and then use textView.getId()
.
Upvotes: 1