Need unique IDs everywhere for using @InjectView?

34 views
Skip to first unread message

John

unread,
Mar 10, 2014, 1:36:41 PM3/10/14
to robo...@googlegroups.com
Hi,

I have a Drawer layout, and 2 of the menu's entries will display a ViewPager. Something like:

click on item 0: display ViewPagerFragment1
click on item 1: display ViewPagerFragment2

Each fragment uses a separate layout, but both have a ViewPager defined like this:

<android.support.v4.view.ViewPager
    android:id="@+id/viewPagerProfile"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    />

In each Fragment, to access the ViewPager, I use:

@InjectView(R.id.viewPager)
private ViewPager viewPager;

If I print the ViewPager onViewCreated:
ViewPagerFragment1:
I/System.out(21911):  view pager stats: android.support.v4.view.ViewPager{425b7b80 VFED.... ......I. 0,0-0,0 #7f0a003a app:id/viewPager}
ViewPagerFragment2:
I/System.out(21911):  view pager profile: android.support.v4.view.ViewPager{424ccf60 VFED.... ......I. 0,0-0,0 #7f0a003a app:id/viewPager}

Note: in that case, I don't get the expected display, one on the ViewPager is empty.

But if I use a different ID for the ViewPager:
ViewPagerFragment1:
I/System.out(22374):  view pager stats: android.support.v4.view.ViewPager{428c30d0 VFED.... ......I. 0,0-0,0 #7f0a0042 app:id/viewPager}
ViewPagerFragment2:

I/System.out(22374):  view pager profile: android.support.v4.view.ViewPager{42653260 VFED.... ......I. 0,0-0,0 #7f0a003a app:id/viewPagerProfile}

The views are displayed correctly.

When using @InjectView, do I need to provide an unique ID for each objects even they don't belong to the same layout?

John

unread,
Mar 13, 2014, 12:06:03 PM3/13/14
to robo...@googlegroups.com
Nevermind that, it's actually an Android issue

Michael Burton

unread,
Mar 13, 2014, 12:29:09 PM3/13/14
to robo...@googlegroups.com
Good to know, thanks for the update

--
You received this message because you are subscribed to the Google Groups "roboguice" group.
To unsubscribe from this group and stop receiving emails from it, send an email to roboguice+...@googlegroups.com.
To post to this group, send email to robo...@googlegroups.com.
Visit this group at http://groups.google.com/group/roboguice.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages