Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to display Fragment containing custom SurfaceView
    primarykey
    data
    text
    <p>This following setup does not work, does anybody know why (I cant seem to find examples of custom surface view in a fragment).</p> <p>My surfaceView class is just hollow at the moment:</p> <pre><code>class MySurfaceView extends SurfaceView implements Runnable{ public MySurfaceView(Context context) { super(context); // TODO Auto-generated constructor stub } @Override public void run() { // TODO Auto-generated method stub } } </code></pre> <p>My XML for the fragment looks like this:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/LinearLayout2" android:layout_width="500dp" android:layout_height="600dp" android:layout_gravity="fill" android:background="#000000" &gt; &lt;Button android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button" /&gt; &lt;com.example.android.fragments.MySurfaceView android:id="@+id/surfaceview" android:layout_width="wrap_content" android:layout_height="wrap_content"/&gt; &lt;/LinearLayout&gt; </code></pre> <p>And then in the actual Fragment itself on the OnCreateView I call :</p> <pre><code> return inflater.inflate(R.layout.article_view, container, false); </code></pre> <p>Any ideas why this does not hang together ?</p> <p>It something to do with the XML because when I do</p> <pre><code>&lt;SurfaceView android:id="@+id/surfaceview" android:layout_width="wrap_content" android:layout_height="wrap_content"/&gt; </code></pre> <p>Then it works fine.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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