Android Fabric Twitter Timeline -
i trying show user timeline in android fragment. homefragment.java oncreate() looks this:
public class homefragment extends listfragment { @injectview(android.r.id.list) listview mtimeline; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); if (getarguments() != null) { msectionnumber = getarguments().getint(arg_section_number); } final usertimeline usertimeline = new usertimeline.builder().screenname("fabric").build(); final tweettimelinelistadapter adapter = new tweettimelinelistadapter(getactivity(), usertimeline); setlistadapter(adapter); }
and fragment_home.xml has listview:
<listview android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@android:id/list" android:layout_alignparenttop="true" android:layout_centerhorizontal="true"/>
homefragment fragment of homeactivity. code shows empty list. how fix problem? know how setlistadapter(adapter);
works. how know list set adapter since can't called on particular list. used twitter fabric page reference when writing code.
inflate custom layout fragment_home.xml in listfragment
by overriding oncreateview
.
@override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { return inflater.inflate(r.layout.fragment_home, container, false); }
your layout contains listview
special @android:id/list
id identifies listview
listfragment's setlistadapter use.
also, tweettimelinelistadapter
listadapter
. if you'd find own listview
, set adapter yourself, use ordinary fragment
(not listfragment
).
mtimeline.setlistadapter(adapter) // mtimeline listview
the docs include listfragment example.
Comments
Post a Comment