Friday, February 14, 2014

ListView join Viewpager problem


How to get the listview join viewpager android: id = "@ id / android: list" of listView.
Problem Description:
According to the conventional method is to get LayoutInflater online where the XML object
ListViewThen findViewById (R.id.listView) to get ListView object, as follows:

 View convertView0 = viewInflater.inflate (R.layout.todaynews_, null); 
LinearLayout linearLayout0 = (LinearLayout) convertView0
. FindViewById (R.id.todayNewsLayout);
listView = (ListView) convertView0
. FindViewById (R.id.listView);


The problem is the code I used the setListAdapter (adapter), this method requires a ListView id be so defined: android: id = "@ id / android: list". Because there is no custom id value, so can not be used
 listView = (ListView) convertView0.findViewById (R.id.listView) 
to get a listView object, but can not use getListView () (because the current load is viewpager of ativity, will use this null pointer), my question is to know how to get listView object, please inform the twelve great gods, grateful.
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
Grandpa had list.setAdapter () on it, beginner android shortcoming.
Reply:

Reply:
setListAdapter (adapter) first saw

Reply:
reference to the third floor pengguohua1988 reply:
setListAdapter (adapter) first saw
activit extend ListActivit can use setListAdapter (adapter) filled listview ah
Reply:
references, 4th Floor rain082900 reply:
Quote: references to the third floor pengguohua1988 reply:

setListAdapter (adapter) first saw
activit extend ListActivit can use setListAdapter (adapter) filled listview ah



Reply:
You use getListView, Activity to inherit ListActivity
If you use an ordinary Activity getListView not get listview, nor can setListAdapter
Reply:
reference to the 6th floor sanjinxiong reply:
you use getListView, Activity to inherit ListActivity
If you use an ordinary Activity getListView not get listview, nor can setListAdapter
ah, learning, thanks, Results posted to the sub.

No comments:

Post a Comment