Tuesday, 15 March 2011

layout - Cannot set id of a fragment in Android -



layout - Cannot set id of a fragment in Android -

i having problem trying give fragments id within xml, cannot seem able that. tried next tutorials, id seems not set fragment. i'm using swipe + sections template supplied. here xml main activity:

<android.support.v4.view.viewpager xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/pager" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".mainactivity" > <!-- title strip display visible page title, page titles adjacent pages. --> <android.support.v4.view.pagertitlestrip android:id="@+id/pager_title_strip" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="top" android:background="#33b5e5" android:paddingbottom="4dp" android:paddingtop="4dp" android:textcolor="#fff" /> <fragment android:id="@+id/account_information_fragment" android:name="com.example.accountinformationfragment" android:layout_width="match_parent" android:layout_height="match_parent" /> </android.support.v4.view.viewpager>

and in fragment class utilize set layout:

final view view = inflater.inflate(r.layout.account_information_layout, container, false);

and layout doesn't contain tags. help much appreciated

i think found problem. first off, fragment tag needs start lower-case f, so:

good:

<fragment>

bad:

<fragment>

secondly, afraid forgot toast homecoming false when trying display non-string. have utilize

string.valueof(fragment.getid());

in order show in toast.

i have no thought why wasn't working @ first since believe tried both f , f tag earlier. setting android:tag helped me debug because returns string naturally.

android layout fragment

No comments:

Post a Comment