Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid: ListView doesn't show anything on Tablet mode
    text
    copied!<p>I have an app that supposed to run on tablet and phone. For the tablet layout I create this layout, so it starts two fragment:</p> <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/linearLayout1" android:layout_width="fill_parent" android:layout_height="fill_parent" &gt; &lt;fragment android:id="@+id/search_panel_fragment" android:name="adam.czibere.fragments.tablet.SearchPanelFragment" android:layout_width="wrap_content" android:layout_height="match_parent" android:tag="search_panel" /&gt; &lt;fragment android:id="@+id/search_list_fragment" android:name="adam.czibere.fragments.tablet.SearchListFragment" android:layout_width="wrap_content" android:layout_height="match_parent" android:tag="search_list" /&gt; &lt;/LinearLayout&gt; </code></pre> <p>So far so good, the fragments shows their views. The two fragment's host activity is SearchActivity.</p> <pre><code> public class SearchListFragment extends Fragment { private SearchEventListener seListener; @Override public void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); } @Override public void onAttach(Activity activity) { super.onAttach(activity); try { seListener = (SearchEventListener) activity; } catch (ClassCastException e) { throw new ClassCastException(activity.toString() + " must implement SearchListFragmentListener"); } } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // TODO Auto-generated method stub View v = inflater.inflate(R.layout.kurva_lista, container, false); SearchActivity sa = (SearchActivity) getActivity(); ListView list = (ListView) v.findViewById(R.id.listView1); list.setAdapter(sa.mobileAdapter); list.setOnScrollListener(new OnScrollListener() { @Override public void onScrollStateChanged(AbsListView view, int scrollState) { // TODO Auto-generated method stub } @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { // TODO Auto-generated method stub seListener.onListScrolled(view, firstVisibleItem, visibleItemCount, totalItemCount); } }); return v; } } </code></pre> <p>When I click the searchbutton on the SearchPanelFragment, it makes a list for the adapter and calls a notifyDataSetChanged(), but nothing can be seen on the screen. I checked, the adapter, it has some values (getgropuCount not gives back 0 ). My adapter's getView method is not getting called at all. The strange thing, that if I try it on mobile phone, it works, it populates the list. (I am using another fragment on phone, but it does the same thing. In phone mode, only one fragment can be seen on screen)</p> <p>This is the adapter:</p> <pre><code> public class MobileSearchListAdapter extends BaseAdapter{ private List&lt;VCDR&gt; items; VCDR lastElementOnScreen; private Context context; public MobileSearchListAdapter( Context c,List&lt;VCDR&gt; objects) { items=objects; context=c; // TODO Auto-generated constructor stub } @Override public View getView(int position, View convertView, ViewGroup parent) { // TODO Auto-generated method stub if (convertView == null) { LayoutInflater infalInflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); convertView = infalInflater.inflate(R.layout.search_list_item_viewpager, null); } VCDR currentItem=(VCDR) getItem(position); lastElementOnScreen=currentItem; TextView date= (TextView) convertView.findViewById(R.id.date); TextView dur = (TextView) convertView.findViewById(R.id.duration); TextView caller_name = (TextView) convertView.findViewById(R.id.caller_name); TextView caller_num = (TextView) convertView.findViewById(R.id.caller_number); TextView called_num = (TextView) convertView.findViewById(R.id.called_number); TextView called_name = (TextView) convertView.findViewById(R.id.caller_name); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat timeFormat = new SimpleDateFormat("HH:mm:ss"); date.setText(dateFormat.format(currentItem.getStartTime()) + " " + timeFormat.format(currentItem.getStartTime())); dur.setText(timeFormat.format(currentItem.getDuration())); called_name.setText(currentItem.getDestinationNameD()); caller_name.setText(currentItem.getSourceName()); called_num.setText(currentItem.getDestinationCallerID()); called_num.setText(currentItem.getSourceCallerID()); return convertView; } public VCDR getLastVisibleElemnt(){ return lastElementOnScreen; } @Override public int getCount() { // TODO Auto-generated method stub return items.size(); } @Override public Object getItem(int arg0) { // TODO Auto-generated method stub return items.get(arg0); } @Override public long getItemId(int arg0) { // TODO Auto-generated method stub return 0; } </code></pre> <p>}</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload