I am creating a list which will be placed under another view, based on the other article, the header of the list view Should include other footage in I am using ListFragment and will be associated with many activities. So I'm making a method to set the header of ListFragment.
The problem is the getListView () method is returning empty, although I call addHeader after the list is shown.
Why is getListView () always empty?
This is my code:
Provides public class NewsstandFragment list extension {Private Final Final Top News Count = 5; Private DBNewsDataSource dataSource; Personal activity myActivity; Personal reference myContext; Private boolean ishim; Override public null at @activityCreated (bundled saved instenstate) {super. Current activity (saved instance); Yesh = true; MyActivity = getActivity (); Bundle Extra = myActivity.getIntent (). GetExtras (); If (extra! = Null) {hashom = extras.jetbolian ("hahommom"); } Data source = new dbn datasource ()); DataSource.open (); & Lt; DBNews & gt; News = datasource.get news (); & Lt; String & gt; TitleList = New Arrestist & lt; String & gt; (); DataSource.close (); For (Int i = 0; I & lt; (hash? Top news source: newsjies); +++ {titleList.add (news.jet (i) .getTitle ()); } NewsLearrereadapter adapter = new newsletter, news, title list, hahom); SetListAdapter (adapter); } @ Override Public Wide OnlistEystemClick (ListView L, View V, Int Position, Long ID) {// Do something with data} Public Zero Adhider (see V) {ListView lv = getListView (); Lv.addHeaderView (v); } This is an activity that calls a piece
increases the public square home activity activity {@ Override Protected Bundle at Protected Zero Gaya InstanceState) {super.onCreate (savedInstanceState); This.requestWindowFeature (Window.FEATURE_NO_TITLE); SetContentView (R.layout.template_activity_home); Piece Manager Piece Manager = getFragmentManager (); Piece Transaction Piece Transaction = Piece MANAGER.beginTransaction (); NewsstandFragment frignews = new newsletterfragment (); MenslideShophraagment frgSS = New Men's Slide ShowFragment (); See VW = frgSS.getView (); FrgNews.addHeader (VW); FragmentTransaction.add (R.id.layout_news_list, frgNews (piece); FragmentTransaction.commit (); //frgNews.addHeader(vw); }
Override the ordered view and it gives a view that includes a ListView id Together with Android: id = "@ android: id / list" @ override public view creatives (layoutInfleter Inflator, View Group container, bundle savedinstenstate) {See view = inflater.inflate (R.layout.cart_list, tap); Return view; }
No comments:
Post a Comment