Inheritance: android.view.View, android.view.ViewTreeObserver.OnPreDrawListener
        protected override void onCreate(global::android.os.Bundle savedInstanceState)
        {
            base.onCreate(savedInstanceState);
            var ll = new LinearLayout(this);
            ll.setOrientation(LinearLayout.VERTICAL);

            textLatitude = new TextView(this).AttachTo(ll);
            textLongitude = new TextView(this).AttachTo(ll);

            textLatitude.setText("?");
 
            setContentView(ll);

            locationManager = (LocationManager)this.getSystemService(Context.LOCATION_SERVICE);
            Location lastLocation = locationManager.getLastKnownLocation(PROVIDER);
            if (lastLocation != null)
            {
                updateLoc(lastLocation);
            }

            this.myLocationListener = new MyLocationListener
            {
                __this = this
            };

            this.ShowToast("http://jsc-solutions.net");
        }
        // inspired by http://android-er.blogspot.com/2011/06/simple-example-using-androids-sqlite.html
        // http://blog.kurtschindler.net/post/getting-started-with-sqlite-and-net

       

        protected override void onCreate(global::android.os.Bundle savedInstanceState)
        {

            base.onCreate(savedInstanceState);

            var ll = new LinearLayout(this);


            setContentView(ll);

            TextView listContent = new TextView(this).AttachTo(ll);


            __SQLiteConnectionHack.Context = this;

            MyDatabase.Write();


            var contentRead = "-";

            contentRead = MyDatabase.Read(contentRead);

            listContent.setText(contentRead);

            this.ShowToast("http://jsc-solutions.net");
        }
        protected override void onCreate(global::android.os.Bundle savedInstanceState)
        {
            // http://www.dreamincode.net/forums/topic/130521-android-part-iii-dynamic-layouts/

            base.onCreate(savedInstanceState);

            var sv = new ScrollView(this);
            var ll = new LinearLayout(this);
            ll.setOrientation(0);
            sv.addView(ll);

            var key = new TextView(this).AttachTo(ll);
            var value = new TextView(this).AttachTo(ll);
            var xml = new TextView(this).AttachTo(ll);

            key.setText("foo");
            value.setText("bar");

            xml.setText(
             new XElement("KeyValuePair",
                 new XAttribute("Key", "foo"),
                 new XElement("Value", "bar")
             ).ToString()
            );

            setContentView(sv);

            //this.ShowToast("http://jsc-solutions.net");
        }
        TextView zCoor; // declare Z axis object

        // running it on device:
        // attach device to usb

        protected override void onCreate(global::android.os.Bundle savedInstanceState)
        {
            // http://www.dreamincode.net/forums/topic/130521-android-part-iii-dynamic-layouts/

            base.onCreate(savedInstanceState);

            var sv = new ScrollView(this);
            var ll = new LinearLayout(this);
            ll.setOrientation(LinearLayout.VERTICAL);
            sv.addView(ll);

            xCoor = new TextView(this).AttachTo(ll);
            yCoor = new TextView(this).AttachTo(ll);
            zCoor = new TextView(this).AttachTo(ll);
            setContentView(sv);

            this.onaccelerometer +=
                (x, y, z) =>
                {
                    xCoor.setText("X: " + ((object)x).ToString());
                    yCoor.setText("Y: " + ((object)y).ToString());
                    zCoor.setText("Z: " + ((object)z).ToString());
                };



            //setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

            //this.ShowToast("http://jsc-solutions.net");
        }
        protected override void onCreate(global::android.os.Bundle savedInstanceState)
        {
            // http://www.dreamincode.net/forums/topic/130521-android-part-iii-dynamic-layouts/

            base.onCreate(savedInstanceState);

            ScrollView sv = new ScrollView(this);

            LinearLayout ll = new LinearLayout(this);

            ll.setOrientation(LinearLayout.VERTICAL);

            sv.addView(ll);

            //// http://stackoverflow.com/questions/9784570/webview-inside-scrollview-disappears-after-zooming
            //// http://stackoverflow.com/questions/8123804/unable-to-add-web-view-dynamically
            //// http://developer.android.com/reference/android/webkit/WebView.html



            TextView tv = new TextView(this);

            tv.setText("What would you like to create today?");

            ll.addView(tv);



            this.setContentView(sv);

            var version = SDKVersionCheck.GetSDKVersion();

            this.ShowLongToast(new { version }.ToString());

        }
        public override void InternalBeforeSetContext(android.content.Context c)
        {
            // http://stackoverflow.com/questions/15556168/android-set-just-one-padding-of-textview-programmatically
            InternalTextView = new TextView(c);
            InternalTextView.setPadding(4, 4, 4, 4);
            // X:\jsc.svn\examples\java\android\forms\FormsShowDialog\FormsShowDialog\Library\Form1.cs

            InternalSetText(InternalText);
        }
        protected override void onCreate(global::android.os.Bundle savedInstanceState)
        {
            base.onCreate(savedInstanceState);

            setContentView(R.layout.main);

            myPath = (TextView)findViewById(R.id.path);


            root = android.os.Environment.getExternalStoragePublicDirectory(
                                                android.os.Environment.DIRECTORY_PICTURES
                                                ).getPath();

            //root = Environment.getRootDirectory().getPath();

            getDir(root);


            this.ShowToast("http://jsc-solutions.net");
        }
Exemple #8
0
 protected override void onCreate (android.os.Bundle arg0)
 {
     base.onCreate (arg0);
     
     LinearLayout layout = new LinearLayout (this);
     layout.setOrientation (LinearLayout.VERTICAL);
     Button btn = new Button (this);
     btn.setOnClickListener (this);
     btn.setText ("threaD");
     layout.addView (btn);
     
     btn2 = new Button (this);
     btn2.setText ("debug");
     btn2.setOnClickListener (new com.koushikdutta.monojavabridge.android.OnClickListener { OnClick = v =>
     {
         Console.WriteLine ("Foobar");
     } });
     layout.addView (btn2);
     
     tv = new TextView(this);
     layout.addView(tv);
     setContentView (layout);
     
 }
        // http://www.techwavedev.com/?p=14
        // http://www.androidhive.info/2011/08/android-tab-layout-tutorial/
        // http://stackoverflow.com/questions/6685257/android-tabhost-addtab-null-pointer-exception
        // http://stackoverflow.com/questions/6674044/android-application-is-not-runnning-errorresourcesnotfoundexception-resource
        // http://www.devdaily.com/java/jwarehouse/android/core/java/android/widget/TabHost.java.shtml

        protected override void onCreate(global::android.os.Bundle savedInstanceState)
        {
            // http://www.dreamincode.net/forums/topic/130521-android-part-iii-dynamic-layouts/

            base.onCreate(savedInstanceState);

            var c = this;

            var th = new TabHost(c);

            LinearLayout ll = new LinearLayout(this);

            ll.setOrientation(LinearLayout.VERTICAL);

            th.addView(ll);


            var tw = new TabWidget(c);
            tw.setId(android.R.id.tabs);
            tw.AttachTo(ll);

            var fl = new FrameLayout(c);
            fl.setId(android.R.id.tabcontent);
            fl.AttachTo(ll);


            //th.str

            this.setContentView(th);


            //  Your TabHost must have a TabWidget whose id attribute is 'android.R.id.tabs'
            // what?
            // android.widget.TabHost cannot be cast to android.widget.TabWidget
            th.setup();
            // for some reason R.layout.tab_indicator cannot be loaded and causes a fault!
            // http://www.devdaily.com/java/jwarehouse/android/core/java/android/widget/TabHost.java.shtml
            // http://ericharlow.blogspot.com/2010/10/experience-customizing-androids-tab.html

            {
                var a = new TextView(c);

                a.setText("Hello1");

                var ts =
                    th
                    .newTabSpec("")
                    .setIndicator(
                    a
                    //(CharSequence)(object)"Hello"
                    //,  res.getDrawable(R.drawable.ic_tab_main)
                    )
                    .setContent(

                        new XTabContentFactory { c = this }

                    );

                //E/AndroidRuntime( 1610): Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x0
                //E/AndroidRuntime( 1610):        at android.content.res.Resources.getValue(Resources.java:1018)
                //E/AndroidRuntime( 1610):        at android.content.res.Resources.loadXmlResourceParser(Resources.java:2105)
                //E/AndroidRuntime( 1610):        at android.content.res.Resources.getLayout(Resources.java:857)
                //E/AndroidRuntime( 1610):        at android.view.LayoutInflater.inflate(LayoutInflater.java:394)
                //E/AndroidRuntime( 1610):        at android.widget.TabHost$LabelIndicatorStrategy.createIndicatorView(TabHost.java:531)
                //E/AndroidRuntime( 1610):        at android.widget.TabHost.addTab(TabHost.java:223)
                //E/AndroidRuntime( 1610):        at AndroidTabViewActivity.Activities.ApplicationActivity.onCreate(ApplicationActivity.java:54)

                th.addTab(ts
                );
            }

            {
                var a = new TextView(c);

                a.setText("Hello2");

                var ts =
                    th
                    .newTabSpec("")
                    .setIndicator(
                    a
                    //(CharSequence)(object)"Hello"
                    //,  res.getDrawable(R.drawable.ic_tab_main)
                    )
                    .setContent(

                        new YTabContentFactory { c = this }

                    );

                //E/AndroidRuntime( 1610): Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x0
                //E/AndroidRuntime( 1610):        at android.content.res.Resources.getValue(Resources.java:1018)
                //E/AndroidRuntime( 1610):        at android.content.res.Resources.loadXmlResourceParser(Resources.java:2105)
                //E/AndroidRuntime( 1610):        at android.content.res.Resources.getLayout(Resources.java:857)
                //E/AndroidRuntime( 1610):        at android.view.LayoutInflater.inflate(LayoutInflater.java:394)
                //E/AndroidRuntime( 1610):        at android.widget.TabHost$LabelIndicatorStrategy.createIndicatorView(TabHost.java:531)
                //E/AndroidRuntime( 1610):        at android.widget.TabHost.addTab(TabHost.java:223)
                //E/AndroidRuntime( 1610):        at AndroidTabViewActivity.Activities.ApplicationActivity.onCreate(ApplicationActivity.java:54)

                th.addTab(ts
                );
            }

            //th.addTab(th
            //    .newTabSpec("")
            //    .setIndicator(
            //        (CharSequence)(object)"World"
            //        //,  res.getDrawable(R.drawable.ic_tab_setup)
            //        )
            //    .setContent(new Intent(c, GetMainActivityClass()))
            //);

            this.ShowLongToast("http://jsc-solutions.net");


        }
		/// <summary>
		/// Sets the global references to UI elements and event handlers for those elements.
		/// </summary>
		private void setupViewElements()
		{
			mTitleText = (TextView) findViewById(R.id.titleText);
			mArtistText = (TextView) findViewById(R.id.artistText);
			mCoverArt = (ImageView) findViewById(R.id.coverImage);
			mSeekBar = (SeekBar) findViewById(R.id.musicPosition);
			mPlayButton = (ImageButton) findViewById(R.id.playPause);
			mMuteButton = (ImageButton) findViewById(R.id.mute);
			mPositionText = (TextView) findViewById(R.id.positionText);
			mDurationText = (TextView) findViewById(R.id.durationText);

			mSeekBar.OnSeekBarChangeListener = this;
			mPlayButton.OnClickListener = this;
			mMuteButton.OnClickListener = this;
			mPositionText.Text = "00:00";

			mProgressDialog = new ProgressDialog(this);
			mProgressDialog.Message = "Buffering...";
			mProgressDialog.Cancelable = true;
			mProgressDialog.OnCancelListener = new OnCancelListenerAnonymousInnerClassHelper(this);

			View stopButton = findViewById(R.id.stop);
			stopButton.OnClickListener = this;

			mDevicePicker = (DevicePicker) FragmentManager.findFragmentById(R.id.playerPicker);
			mDevicePicker.DeviceType = SmcDevice.TYPE_AVPLAYER;
			mDevicePicker.DeviceSelectedListener = this;
		}
        public override void createAndAttachView(int id, FrameLayout frame)
        {
            // http://stackoverflow.com/questions/2761577/android-start-an-intent-into-a-framelayout
            // http://gamma-point.com/content/android-how-have-multiple-activities-under-single-tab-tabactivity#comment-37
            // http://stackoverflow.com/questions/4882776/start-another-activity-inside-the-framelayout-of-tabactivity

            //     Caused by: java.lang.RuntimeException: You must attach your view to the given frame in createAndAttachView()
            //at wei.mark.standout.ui.Window.<init>(Window.java:154)
            //at wei.mark.standout.StandOutWindow.show(StandOutWindow.java:1078)
            //at wei.mark.standout.StandOutWindow.onStartCommand(StandOutWindow.java:381)
            //at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2656)

            var ll = new LinearLayout(
               frame.getContext()
            );

            //ll.setAlpha(0.8f);

            ll.setOrientation(LinearLayout.VERTICAL);

            var lltab = new LinearLayout(
              frame.getContext()
            );
            lltab.AttachTo(ll);


            #region caption
            var caption = new TextView(frame.getContext());

            caption.setText(" XWidgetsWindow");
            // http://stackoverflow.com/questions/3297437/shadow-effect-for-a-text-in-android
            caption.setShadowLayer(1, 0, 0, Color.WHITE);
            caption.setTextColor(Color.WHITE);
            caption.setBackgroundColor(Color.BLACK);

            caption.AttachTo(lltab);
            #endregion


            #region close
            var close = new TextView(frame.getContext());

            close.setText("  x  ");
            // http://stackoverflow.com/questions/3297437/shadow-effect-for-a-text-in-android
            close.setShadowLayer(1, 0, 0, Color.RED);
            close.setTextColor(Color.RED);
            close.setBackgroundColor(Color.BLACK);

            close.AttachTo(lltab);
            close.setClickable(true);

            close.AtClick(
                delegate
                {

                    this.close(id);
                }
            );
            #endregion

            #region WebView
            var webview = new WebView(frame.getContext());
            webview.setAlpha(0.8f);

            //getWindow().setFlags(
            //    WindowManager_LayoutParams.FLAG_HARDWARE_ACCELERATED,
            //    WindowManager_LayoutParams.FLAG_HARDWARE_ACCELERATED);

            //setContentView(webview);

            //webview.getSettings().setSupportZoom(true); 
            //webview.getSettings().setLoadsImagesAutomatically(true);
            webview.getSettings().setJavaScriptEnabled(true);
            //webview.getSettings().setBuiltInZoomControls(true);
            //webview.setInitialScale(1);

            webview.setWebViewClient(new MyWebViewClient
            {
                //__this = this 
            });

            //webview.getSettings().setSupportZoom(true);
            //webview.setScrollBarStyle(WebView.SCROLLBARS_INSIDE_OVERLAY);

            //webview.getSettings().setJavaScriptEnabled(true);

            // no flash in emulator?
            // works on my phone!
            // no Flash since android 4.1.0!!!
            //webview.getSettings().setPluginsEnabled(true);
            //webview.getSettings().setPluginState(android.webkit.WebSettings.PluginState.ON);



            // OR, you can also load from an HTML string:
            //var summary = "<html><body>You scored <b>192</b> points.</body></html>";
            //webview.loadData(summary, "text/html", null);
            //Log.i(TAG, "loadUrl");

            //var uri = "http://cubiq.org/dropbox/3dcity/";
            //var uri = "http://abstractatech.com";
            var uri = "http://webglreport.com";
            webview.loadUrl(uri);
            #endregion

            // http://forum.xda-developers.com/showthread.php?t=1688531

            var rr = new RelativeLayout(frame.getContext());


            webview.AttachTo(rr);

            #region resizer

            var resizer = new Button(frame.getContext());

            resizer.setText(".:");
            resizer.setAlpha(0.4f);

            resizer.setWidth(72);
            resizer.setHeight(72);


            // http://stackoverflow.com/questions/8397152/androidlayout-alignparentbottom-by-code
            // http://stackoverflow.com/questions/8397152/androidlayout-alignparentbottom-by-code




            resizer.AttachTo(rr);

            RelativeLayout.LayoutParams p = new RelativeLayout.LayoutParams(
               RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT
             );

            p.setMargins(128 + 64, 128 + 64, 0, 0);
            resizer.setLayoutParams(p);



            resizer.setOnTouchListener(
                new __OnTouchListener
                {
                    yield = (view, e) =>
                    {
                        wei.mark.standout.ui.Window ww = getWindow(id);

                        // handle dragging to move
                        var consumed = this.onTouchHandleResize(id,
                            ww,
                            view,
                            e
                        );

                        {
                            p.setMargins(ww.getWidth() - 64 + 8, ww.getHeight() - 64 - 24, 0, 0);
                            resizer.setLayoutParams(p);
                        }
                        return consumed;
                    }
                }
            );
            #endregion

            rr.AttachTo(ll);
            ll.AttachTo(frame);

            {
                //Caused by: java.lang.ClassCastException: android.widget.LinearLayout$LayoutParams cannot be cast to wei.mark.standout.StandOutWindow$StandOutLayoutParams
                //at wei.mark.example.XWidgetsWindow.createAndAttachView(XWidgetsWindow.java:101)
                //at wei.mark.standout.ui.Window.<init>(Window.java:150)
                //at wei.mark.standout.StandOutWindow.show(StandOutWindow.java:1078)
                //at wei.mark.standout.StandOutWindow.onStartCommand(StandOutWindow.java:381)
                //at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2656)

                //p.setMargins(ww.getWidth() - 64, ww.getHeight() - 64 - 32, 0, 0);
                //resizer.setLayoutParams(p);
            }
        }
        public override void createAndAttachView(int id, FrameLayout frame)
        {
            // http://stackoverflow.com/questions/2761577/android-start-an-intent-into-a-framelayout
            // http://gamma-point.com/content/android-how-have-multiple-activities-under-single-tab-tabactivity#comment-37
            // http://stackoverflow.com/questions/4882776/start-another-activity-inside-the-framelayout-of-tabactivity

            //     Caused by: java.lang.RuntimeException: You must attach your view to the given frame in createAndAttachView()
            //at wei.mark.standout.ui.Window.<init>(Window.java:154)
            //at wei.mark.standout.StandOutWindow.show(StandOutWindow.java:1078)
            //at wei.mark.standout.StandOutWindow.onStartCommand(StandOutWindow.java:381)
            //at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2656)

            var ll = new LinearLayout(
               frame.getContext()
            );

            //ll.setAlpha(0.8f);

            ll.setOrientation(LinearLayout.VERTICAL);

            #region lltab
            var lltab = new LinearLayout(
              frame.getContext()
            );
            lltab.AttachTo(ll);


            var captionpadding = new TextView(frame.getContext());

            captionpadding.setText("    ");
            // http://stackoverflow.com/questions/3297437/shadow-effect-for-a-text-in-android
            captionpadding.setShadowLayer(1, 0, 0, Color.WHITE);
            captionpadding.setTextColor(Color.WHITE);
            captionpadding.setBackgroundColor(Color.argb(0x7F, 0, 0, 0));

            captionpadding.AttachTo(lltab);

            var caption = new TextView(frame.getContext());

            caption.setText("XWidgetsWindow");
            // http://stackoverflow.com/questions/3297437/shadow-effect-for-a-text-in-android
            caption.setShadowLayer(1, 0, 0, Color.WHITE);
            caption.setTextColor(Color.WHITE);
            caption.setBackgroundColor(Color.argb(0x7F, 0, 0, 0));

            caption.AttachTo(lltab);


            var close = new TextView(frame.getContext());

            close.setText("    x    ");
            // http://stackoverflow.com/questions/3297437/shadow-effect-for-a-text-in-android
            close.setShadowLayer(1, 0, 0, Color.RED);
            close.setTextColor(Color.RED);
            close.setBackgroundColor(Color.argb(0x7F, 0, 0, 0));

            close.AttachTo(lltab);
            close.setClickable(true);

            close.AtClick(
                delegate
                {

                    this.close(id);
                }
            );

            #endregion


            //wei.mark.standout.WindowCache r;

            #region WebView
            var webview = new WebView(frame.getContext());
            //webview.setAlpha(0.8f);

            //frame.startAnimation(new AlphaAnimation(1f, 0.7f));

            //     java.lang.NoSuchMethodError: android.webkit.WebView.setAlpha
            //at PopupWebView.Activities.XWidgetsWindow.createAndAttachView(XWidgetsWindow.java:83)
            //at wei.mark.standout.ui.Window.<init>(Window.java:142)
            //at wei.mark.standout.StandOutWindow.show(StandOutWindow.java:1026)
            //at wei.mark.standout.StandOutWindow.onStartCommand(StandOutWindow.java:381)
            //at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2043)
            //at android.app.ActivityThread.access$2800(ActivityThread.java:117)
            //at android.app.ActivityThread$H.handleMessage(ActivityThread.java:998)
            //at android.os.Handler.dispatchMessage(Handler.java:99)
            //at android.os.Looper.loop(Looper.java:123)
            //at android.app.ActivityThread.main(ActivityThread.java:3687)
            //at java.lang.reflect.Method.invokeNative(Native Method)
            //at java.lang.reflect.Method.invoke(Method.java:507)
            //at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842)
            //at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
            //at dalvik.system.NativeStart.main(Native Method)


            //getWindow().setFlags(
            //    WindowManager_LayoutParams.FLAG_HARDWARE_ACCELERATED,
            //    WindowManager_LayoutParams.FLAG_HARDWARE_ACCELERATED);

            //setContentView(webview);

            //webview.getSettings().setSupportZoom(true); 
            //webview.getSettings().setLoadsImagesAutomatically(true);
            webview.getSettings().setJavaScriptEnabled(true);
            //webview.getSettings().setBuiltInZoomControls(true);
            //webview.setInitialScale(1);

            webview.setWebViewClient(new MyWebViewClient
            {
                //__this = this 
            });

            webview.setWebChromeClient(
                new MyWebChromeClient
                {
                    yield_title =
                        // implicit version does not work?
                        value =>
                        {
                            caption.setText(value);

                            PersistentNotifications
                                .Where(k => k.id == id)
                                .WithEach(
                                n =>
                                {
                                    n.contentText = value;

                                    n.Notification.setLatestEventInfo(
                                        n.context,
                                        n.contentTitle,
                                        n.contentText,
                                        n.contentIntent
                                    );
                                    n.update();
                                }
                            );
                        }
                }
            );

            //webview.getSettings().setSupportZoom(true);
            //webview.setScrollBarStyle(WebView.SCROLLBARS_INSIDE_OVERLAY);

            //webview.getSettings().setJavaScriptEnabled(true);

            // no flash in emulator?
            // works on my phone!
            // no Flash since android 4.1.0!!!
            //webview.getSettings().setPluginsEnabled(true);
            //webview.getSettings().setPluginState(android.webkit.WebSettings.PluginState.ON);



            // OR, you can also load from an HTML string:
            //var summary = "<html><body>You scored <b>192</b> points.</body></html>";
            //webview.loadData(summary, "text/html", null);
            //Log.i(TAG, "loadUrl");

            //var uri = "http://cubiq.org/dropbox/3dcity/";
            var uri = "http://abstractatech.com";
            webview.loadUrl(uri);
            #endregion

            // http://forum.xda-developers.com/showthread.php?t=1688531

            var rr = new RelativeLayout(frame.getContext());

            rr.setBackgroundColor(Color.argb(0x1F, 255, 255, 255));

            webview.AttachTo(rr);

            var resizer = new Button(frame.getContext());

            resizer.setText(".:");
            //resizer.setAlpha(0.4f);

            resizer.setWidth(96);
            resizer.setHeight(96);
            resizer.setBackgroundColor(Color.argb(0x7F, 255, 255, 255));



            // http://stackoverflow.com/questions/8397152/androidlayout-alignparentbottom-by-code
            // http://stackoverflow.com/questions/8397152/androidlayout-alignparentbottom-by-code




            resizer.AttachTo(rr);

            RelativeLayout.LayoutParams p = new RelativeLayout.LayoutParams(
               RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT
             );

            //400, 250,
            p.setMargins(400 - 64, 250 - 64 - 32, 0, 0);
            resizer.setLayoutParams(p);



            resizer.setOnTouchListener(
                new __OnTouchListener
                {
                    yield = (view, e) =>
                    {
                        var ww = getWindow(id);

                        // handle dragging to move
                        var consumed = this.onTouchHandleResize(id,
                            ww,
                            view,
                            e
                        );

                        {
                            p.setMargins(ww.getWidth() - 64 + 10, ww.getHeight() - 64 - 20, 0, 0);
                            resizer.setLayoutParams(p);
                        }
                        return consumed;
                    }
                }
            );

            rr.AttachTo(ll);
            ll.AttachTo(frame);

            {
                //Caused by: java.lang.ClassCastException: android.widget.LinearLayout$LayoutParams cannot be cast to wei.mark.standout.StandOutWindow$StandOutLayoutParams
                //at wei.mark.example.XWidgetsWindow.createAndAttachView(XWidgetsWindow.java:101)
                //at wei.mark.standout.ui.Window.<init>(Window.java:150)
                //at wei.mark.standout.StandOutWindow.show(StandOutWindow.java:1078)
                //at wei.mark.standout.StandOutWindow.onStartCommand(StandOutWindow.java:381)
                //at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2656)

                //p.setMargins(ww.getWidth() - 64, ww.getHeight() - 64 - 32, 0, 0);
                //resizer.setLayoutParams(p);
            }
        }
        protected override void onCreate(Bundle savedInstanceState)
        {
            base.onCreate(savedInstanceState);

            var sv = new ScrollView(this);
            var ll = new LinearLayout(this);
            ll.setOrientation(LinearLayout.VERTICAL);
            sv.addView(ll);

            new Button(this)
                .WithText("Create Event!")
                .AttachTo(ll)
                .AtClick(
                    b =>
                    {
                        b.setText("Done!");

                        // http://developer.android.com/reference/android/provider/CalendarContract.EventsColumns.html#DESCRIPTION

                        Intent calIntent = new Intent(Intent.ACTION_INSERT);
                        calIntent.setType("vnd.android.cursor.item/event");
                        calIntent.putExtra("title", "My House Party");
                        calIntent.putExtra("eventLocation", "My Beach House");
                        calIntent.putExtra("description", "A Pig Roast on the Beach");

                        GregorianCalendar calDate = new GregorianCalendar(2012, 7, 15);
                        calIntent.putExtra(CalendarContract.EXTRA_EVENT_ALL_DAY, true);
                        calIntent.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME,
                             calDate.getTimeInMillis());
                        calIntent.putExtra(CalendarContract.EXTRA_EVENT_END_TIME,
                             calDate.getTimeInMillis());





                        //ttdw


                        calIntent.putExtra("accessLevel", 0x00000002);
                        calIntent.putExtra("availability", 0x00000000);

                        calIntent.putExtra("rrule", "FREQ=WEEKLY;COUNT=10;WKST=SU;BYDAY=TU,TH");

                        startActivity(calIntent);
                    }
            );

            var COLS = new[]
            { 
                "title",
                "dtstart"
            };


            var at = new TextView(this).AttachTo(ll);

            at.setText("at " + CalendarContract.Events.CONTENT_URI.ToString());

            // from t in calendars
            // select t.title

            var mCursor = this.getContentResolver().query(
                CalendarContract.Events.CONTENT_URI, COLS, null, null, null
            );

            mCursor.moveToLast();

            var tv = new TextView(this).AttachTo(ll);
            tv.setText("n/a");
            Action update =
                delegate
                {
                    var title = "";
                    var start = "";
                    var w = "";

                    //Format df = android.text.format.DateFormat.getDateFormat(this);
                    //Format tf = android.text.format.DateFormat.getTimeFormat(this);

                    //try
                    //{
                    title = mCursor.getString(0);
                    start = ((object)mCursor.getLong(1)).ToString();


                    w += title;
                    w += " at ";
                    w += start;

                    tv.setText(w);
                    //}
                    //catch
                    //{
                    //    tv.setText("n/a error");

                    //    throw;
                    //}



                };

            Button prev, next = null;

            prev = new Button(this)
                  .WithText("Prev")
                  .AttachTo(ll)
                  .AtClick(
                      b =>
                      {
                          if (!mCursor.isFirst())
                          {
                              mCursor.moveToPrevious();
                              next.setEnabled(true);
                          }
                          else
                              b.setEnabled(false);

                          update();
                      }
            );

            next = new Button(this)
                .WithText("Next")
                .AttachTo(ll)
                .AtClick(
                    b =>
                    {

                        if (!mCursor.isLast())
                        {
                            mCursor.moveToNext();
                            prev.setEnabled(true);
                        }
                        else
                            b.setEnabled(false);

                        update();
                    }
          );

            update();


            this.setContentView(sv);
        }
            public CardboardOverlayEyeView(Context context, AttributeSet attrs)
                : base(context, attrs)
            {
                imageView = new ImageView(context, attrs);
                imageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
                imageView.setAdjustViewBounds(true);  // Preserve aspect ratio.
                addView(imageView);

                textView = new TextView(context, attrs);
                textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14.0f);
                textView.setTypeface(textView.getTypeface(), Typeface.BOLD);
                textView.setGravity(Gravity.CENTER);
                textView.setShadowLayer(3.0f, 0.0f, 0.0f, Color.DKGRAY);
                addView(textView);
            }
        protected override void onCreate(global::android.os.Bundle savedInstanceState)
        {
            // http://www.dreamincode.net/forums/topic/130521-android-part-iii-dynamic-layouts/

            base.onCreate(savedInstanceState);

            ScrollView sv = new ScrollView(this);

            LinearLayout ll = new LinearLayout(this);

            MainView = ll;

            ll.setOrientation(LinearLayout.VERTICAL);

            sv.addView(ll);

            //// http://stackoverflow.com/questions/9784570/webview-inside-scrollview-disappears-after-zooming
            //// http://stackoverflow.com/questions/8123804/unable-to-add-web-view-dynamically
            //// http://developer.android.com/reference/android/webkit/WebView.html



            TextView title = new TextView(this);
            title.setText("JSC Shopping Cart 2");
            ll.addView(title);

            TextView namelabel1 = new TextView(this);
            namelabel1.setText("First Name:");
            ll.addView(namelabel1);


            EditText nameET = new EditText(this);
            nameET.setText("");
            ll.addView(nameET);


            TextView lastnamelabel1 = new TextView(this);
            lastnamelabel1.setText("Last Name:");
            ll.addView(lastnamelabel1);


            EditText lastnameET = new EditText(this);
            lastnameET.setText("");
            ll.addView(lastnameET);


            TextView pkglabel1 = new TextView(this);
            pkglabel1.setText("Select Package:");
            //ll.addView(pkglabel1);

            RadioButton personalRb = new RadioButton(this);
            personalRb.setText("Personal License ($200)");
            //personalRb.AttachTo(ll);

            RadioButton enterpriseRb = new RadioButton(this);
            enterpriseRb.setText("Enterprise License ($400)");
            //enterpriseRb.AttachTo(ll);

            RadioButton commercialRb = new RadioButton(this);
            commercialRb.setText("Commercial License ($600)");
            //commercialRb.AttachTo(ll);

            RadioGroup groupRb = new RadioGroup(this);
            groupRb.addView(personalRb);
            groupRb.addView(enterpriseRb);
            groupRb.addView(commercialRb);
            groupRb.AttachTo(ll);

            Button submitBtn = new Button(this);
            submitBtn.setText("Submit");
            submitBtn.setOnClickListener(new Listener(ll));
            ll.addView(submitBtn);

            this.setContentView(sv);

            this.ShowLongToast("http://jsc-solutions.net");


        }
Exemple #16
0
		/// <summary>Handles touch events for dragging.</summary>
		/// <remarks>
		/// Handles touch events for dragging.  You may want to do other actions
		/// like moving the cursor on touch as well.
		/// </remarks>
		public static bool onTouchEvent (TextView widget, Spannable buffer, MotionEvent @event)
		{
			DragState[] ds;
			switch (@event.getActionMasked ()) {
			case MotionEvent.ACTION_DOWN:
				{
					ds = buffer.getSpans<DragState> (0, buffer.Length);
					{
						for (int i = 0; i < ds.Length; i++) {
							buffer.removeSpan (ds [i]);
						}
					}
					buffer.setSpan (new DragState (@event.getX (), @event.getY (), widget.getScrollX (), widget.getScrollY ()), 0, 0, SpannedClass.SPAN_MARK_MARK);
					return true;
				}

			case MotionEvent.ACTION_UP:
				{
					ds = buffer.getSpans<DragState> (0, buffer.Length);
					{
						for (int i_1 = 0; i_1 < ds.Length; i_1++) {
							buffer.removeSpan (ds [i_1]);
						}
					}
					if (ds.Length > 0 && ds [0].mUsed) {
						return true;
					} else {
						return false;
					}
					goto case MotionEvent.ACTION_MOVE;
				}

			case android.view.MotionEvent.ACTION_MOVE:
				{
					ds = buffer.getSpans<Touch.DragState> (0, buffer.Length);
					if (ds.Length > 0) {
						if (ds [0].mFarEnough == false) {
							int slop = ViewConfiguration.get (widget.getContext ()).getScaledTouchSlop ();
							if (Math.Abs (@event.getX () - ds [0].mX) >= slop || Math.Abs (@event.getY () - ds [0].mY) >= slop) {
								ds [0].mFarEnough = true;
							}
						}
						if (ds [0].mFarEnough) {
							ds [0].mUsed = true;
							bool cap = (@event.getMetaState () & KeyEvent.META_SHIFT_ON) != 0 ||
								MetaKeyKeyListener.getMetaState (buffer, MetaKeyKeyListener.META_SHIFT_ON) == 1 ||
								MetaKeyKeyListener.getMetaState (buffer, MetaKeyKeyListener.META_SELECTING) != 0;
							float dx;
							float dy;
							if (cap) {
								// if we're selecting, we want the scroll to go in
								// the direction of the drag
								dx = @event.getX () - ds [0].mX;
								dy = @event.getY () - ds [0].mY;
							} else {
								dx = ds [0].mX - @event.getX ();
								dy = ds [0].mY - @event.getY ();
							}
							ds [0].mX = @event.getX ();
							ds [0].mY = @event.getY ();
							int nx = widget.getScrollX () + (int)dx;
							int ny = widget.getScrollY () + (int)dy;
							int padding = widget.getTotalPaddingTop () + widget.getTotalPaddingBottom ();
							Layout layout = widget.getLayout ();
							ny = Math.Min (ny, layout.getHeight () - (widget.getHeight () - padding));
							ny = Math.Max (ny, 0);
							int oldX = widget.getScrollX ();
							int oldY = widget.getScrollY ();
							scrollTo (widget, layout, nx, ny);
							// If we actually scrolled, then cancel the up action.
							if (oldX != widget.getScrollX () || oldY != widget.getScrollY ()) {
								widget.cancelLongPress ();
							}
							return true;
						}
					}
					return false;
				}
			}
			return false;
		}
        protected override void onCreate(Bundle arg0)
        {
            base.onCreate(arg0);

            LinearLayout layout = new LinearLayout(this);
            layout.setOrientation(LinearLayout.VERTICAL);

            TextView tv = new TextView(this);
            tv.setText("Hello");
            tv.setTextSize(20);
            layout.addView(tv);

            tv = new TextView(this);
            tv.setText("World!");
            tv.setTextSize(15);
            tv.setTextColor(unchecked((int)0xFF00FFFF));
            layout.addView(tv);

            button = new Button(this);
            button.setText("wtf");
            layout.addView(button);
            button.setOnClickListener(new OnClickListener()
            {
                OnClick = (v) =>
                {
                    Console.WriteLine(toString());
                    button.setText(System.Environment.TickCount.ToString());
                }
            });
            /* 
             * Normally in Java, you'd handle the onClickListener with an inner class.
             * In C# there is no inner class construct.
            button.setOnClickListener(new OnClickListener()
            {
                @Override
                public void onClick()
                {
                }
            });
            */

            setContentView(layout);
        }