Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This should work</p> <p>Custom View class</p> <pre><code>public class DrawView extends View { private Canvas viewCanvas; public DrawView(Context context) { super(context); setLayoutParams(new LayoutParams(LinearLayout.LayoutParams.FILL_PARENT ,LinearLayout.LayoutParams.FILL_PARENT)); } public DrawView(Context context, AttributeSet attrs) { super(context, attrs); } @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); Paint p = new Paint(); p.setColor(Color.RED); canvas.drawCricle(getWidth()/2,getHeight()/2,50,null); viewCanvas = canvas; } public clearCircle(){ viewCanvas.drawColor(Color.BLACK); } } </code></pre> <p>Activity class should look like this</p> <pre><code>public class KeyboardTopDemo extends Activity { private FrameLayout container; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.ss); container = (FrameLayout)findViewById(R.id.sc); container.addView(new DrawView(this)); } public void clearHandler(View target){ container.getChildAt(0).clearCircle(); } } </code></pre> <p>This is the layout xml file</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical"&gt; &lt;FrameLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="0dip" android:id="@+id/sc" android:scrollbars="horizontal" android:layout_weight="1.0"&gt; &lt;ImageView android:layout_width="fill_parent" android:layout_height="fill_parent" android:src="@drawable/chips"/&gt; &lt;/FrameLayout&gt; &lt;Button android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Clear" android:onClick="clearHandler"/&gt; &lt;/LinearLayout&gt; </code></pre>
    singulars
    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. VO
      singulars
      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