Hi There,

I have created a simple custom view to display a line and added it to
the LinearLayout.

the custom view is displayed on Screen, the other view following the
cusomview never show up on Screen.

Thanks

here is the code:
from the code, I have added a CheckBox to LinearLayout after adding
CustomView




package android.test.custom;

import android.app.Activity;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.os.Bundle;
import android.view.View;
import android.widget.CheckBox;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;

public class Test extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
        //setContentView(R.layout.main);
        LinearLayout ll = new LinearLayout(this);
        ll.addView(new CustomView(this),new
LinearLayout.LayoutParams(
                LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
        ll.setOrientation(LinearLayout.VERTICAL);
        ll.addView(new CheckBox(this),new LinearLayout.LayoutParams(
                LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
        setContentView(ll);
    }
    class CustomView extends View
    {
        public CustomView(Context ctx)
        {
                super(ctx);
        }
                /* (non-Javadoc)
                 * @see android.view.View#onDraw(android.graphics.Canvas)
                 */
                @Override
                protected void onDraw(Canvas canvas) {
                        super.onDraw(canvas);
                        canvas.save();
                        Paint p = new Paint();
                        p.setColor(Color.WHITE);
                        canvas.drawLine(0, 0, 100, 0, p);
                        canvas.restore();
                }
    }
}

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to