Note that there are some explanatory texts on larger screens.

plurals
  1. POPageViewer not showing view via class
    text
    copied!<p>For my app I have a base main activity, which holds a pageviewer. In the activity class I have:</p> <pre><code>MyPagerAdapter adapter = new MyPagerAdapter(this); viewPager.setAdapter(adapter); </code></pre> <p>The adapter class looks like:</p> <pre><code>private class MyPagerAdapter extends PagerAdapter { private ArrayList&lt;LinearLayout&gt; views; public MyPagerAdapter(Context context) { views = new ArrayList&lt;LinearLayout&gt;(); views.add(new questionListView(context)); } @Override public void destroyItem(View view, int arg1, Object object) { ((ViewPager) view).removeView((LinearLayout) object); } @Override public void finishUpdate(View arg0) { } @Override public int getCount() { return views.size(); } @Override public Object instantiateItem(View view, int position) { View myView = views.get(position); ((ViewPager) view).addView(myView); return myView; } @Override public boolean isViewFromObject(View view, Object object) { return view == object; } @Override public void restoreState(Parcelable arg0, ClassLoader arg1) { } @Override public Parcelable saveState() { return null; } @Override public void startUpdate(View arg0) { } } } } </code></pre> <p>The questionListView class looks like:</p> <pre><code>public class questionListView extends LinearLayout { public questionListView(Context context, AttributeSet attrs) { super(context, attrs); init(); } public questionListView(Context context) { super(context); init(); } private void init() { LayoutInflater factory = LayoutInflater.from(getContext()); View myView = factory.inflate(R.layout.view1,null); addView(myView); } } </code></pre> <p>Main activity layout:</p> <pre><code>&lt;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" &gt; &lt;!-- This title strip will display the currently visible page title, as well as the page titles for adjacent pages. --&gt; &lt;android.support.v4.view.PagerTitleStrip android:id="@+id/pager_title_strip" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_gravity="top" android:alpha="4" android:paddingBottom="4dp" android:paddingTop="4dp" android:textColor="#000000" /&gt; &lt;/android.support.v4.view.ViewPager&gt; </code></pre> <p>view1 is a layout view, a linearlayout with other layouts in them.</p> <p>When I run the app the main activity is shown, but the view with the view1-layout is not.</p> <p>Why not, what am I doing wrong here? I'm not getting any errors.</p> <p>rg, Eric</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