Inheritance: android.view.ViewGroup
Exemplo n.º 1
0
        // called by?
        public override void InternalBeforeSetContext(android.content.Context c)
        {
            InternalScrollView = new ScrollView(c);
            InternalLinearLayout = new LinearLayout(c);

            var p = this.Padding;
            InternalLinearLayout.setPadding(
                          p.Left,
                          p.Top,
                          p.Right,
                          p.Bottom
                          );


            // shal we allow dynamic change after we have been shown?
            //InternalLinearLayout.setPadding(
            //    this.Padding.Left,
            //    this.Padding.Top,
            //    this.Padding.Right,
            //    this.Padding.Bottom
            //    );

            InternalLinearLayout.setOrientation(1);

            InternalScrollView.addView(InternalLinearLayout);


            // X:\jsc.svn\examples\java\android\forms\InteractivePortForwarding\InteractivePortForwarding\UserControl1.cs
            if (Load != null)
                Load(this, new EventArgs());
        }
        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());

        }
        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);

            var b = new Button(this).AttachTo(ll);



            b.WithText(Foo.Bar("hello via .java"));
            b.AtClick(
                v =>
                {
                    b.WithText(Foo.Bar("click!"));
                }
            );



            this.setContentView(sv);
        }
        //        connect s6 via usb .
        // turn on wifi!
        // kill adb

        //"x:\util\android-sdk-windows\platform-tools\adb.exe"  tcpip 5555
        // restarting in TCP mode port: 5555

        //13: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
        //    inet 192.168.1.126/24 brd 192.168.1.255 scope global wlan0
        //       valid_lft forever preferred_lft forever

        // on red
        // "x:\util\android-sdk-windows\platform-tools\adb.exe" connect  192.168.1.126:5555
        // connected to 192.168.1.126:5555



        // https://sites.google.com/a/jsc-solutions.net/backlog/knowledge-base/2015/201511/20151121
        // http://stackoverflow.com/questions/17513502/support-for-multi-window-app-development

        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);

            var b = new Button(this);

            b.setText("Vibrate!");

            b.AtClick(
                delegate
                {
                    var vibrator = (Vibrator)this.getSystemService(Context.VIBRATOR_SERVICE);

                    vibrator.vibrate(600);
                }
            );

            ll.addView(b);



            this.setContentView(sv);


            //this.ShowLongToast("http://my.jsc-solutions.net x");
        }
        // 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");
        }
        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(Bundle savedInstanceState)
        {
            base.onCreate(savedInstanceState);

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


            var b = new Button(this);
            b.setText("I don't do anything, but I was added dynamically. :)");
            ll.addView(b);


            Action onclick = delegate
            {
                b.setText("onclick");
            };

            b.setText("before AtClick");
            b.AtClick(
                v =>
                {
                    b.setText("AtClick");
                }
            );

            var b2 = new Button(this);
            b2.setText("The other button!");
            ll.addView(b2);

            this.setContentView(sv);
        }
        // X:\opensource\ovr_mobile_sdk_0.5.0
        // https://developer.oculus.com/downloads/#version=mobile-0.5.0

        //<ItemGroup>
        //  <Content Include="X:\opensource\ovr_mobile_sdk_20141111\VRLib\src\**\*.*">
        //    <Link>opensource\ovr_mobile_sdk_20141111\VRLib\src\%(RecursiveDir)%(FileName)%(Extension)</Link>
        //  </Content>
        //</ItemGroup>

        // https://sites.google.com/a/jsc-solutions.net/work/knowledge-base/15-dualvr/20150402
        // https://sites.google.com/a/jsc-solutions.net/work/knowledge-base/15-dualvr/20141127
        // https://sites.google.com/a/jsc-solutions.net/work/knowledge-base/15-dualvr/20150504/dae

        // http://stackoverflow.com/questions/9821875/where-is-buildconfig-debug
        // tested by?

        protected override void onCreate(global::android.os.Bundle savedInstanceState)
		{
			// cmd /K c:\util\android-sdk-windows\platform-tools\adb.exe logcat
			// Camera PTP

			// http://developer.android.com/guide/topics/ui/notifiers/notifications.html

			base.onCreate(savedInstanceState);

			ScrollView sv = new ScrollView(this);

			LinearLayout ll = new LinearLayout(this);

			ll.setOrientation(LinearLayout.VERTICAL);

			sv.addView(ll);


			Button b = new Button(this);

			b.setText("Notify!");
			int counter = 0;




			ll.addView(b);

			this.setContentView(sv);

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


		}
        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");
        }
        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");
        }
        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);

            var b = new Button(this).AttachTo(ll);


            
            b.WithText("before AtClick");
            b.AtClick(
                v =>
                {
                    b.setText("AtClick");
                }
            );

            var b2 = new Button(this);
            b2.setText("The other button!");
            ll.addView(b2);

            this.setContentView(sv);
        }
        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);

            var b = new Button(this).AttachTo(ll);



            b.WithText("popup");
            b.AtClick(
                v =>
                {
                    XStandOutWindow.closeAll(this, typeof(XWidgetsWindow).ToClass());
                    XStandOutWindow.show(this, typeof(XWidgetsWindow).ToClass(), XStandOutWindow.DEFAULT_ID);

                    this.finish();

                }
            );

            this.setContentView(sv);
        }
        protected override void onCreate(Bundle savedInstanceState)
        {
            var activity = this;

            base.onCreate(savedInstanceState);

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

            var b = new Button(this).AttachTo(ll);



            b.WithText("before AtClick");
            b.AtClick(
                v =>
                {
                    b.setText("AtClick");
                }
            );


        }
        // http://stackoverflow.com/questions/6274141/trigger-background-service-at-a-specific-time-in-android
        // http://stackoverflow.com/questions/7144908/how-is-an-intent-service-declared-in-the-android-manifest
        // http://developer.android.com/guide/topics/manifest/service-element.html


        protected override void onCreate(global::android.os.Bundle savedInstanceState)
        {
            // http://developer.android.com/guide/topics/ui/notifiers/notifications.html

            base.onCreate(savedInstanceState);

            ScrollView sv = new ScrollView(this);

            LinearLayout ll = new LinearLayout(this);

            ll.setOrientation(LinearLayout.VERTICAL);

            sv.addView(ll);

            #region startservice
            var startservice = new Button(this);
            startservice.setText("Start Service to send Notification");
            startservice.AtClick(
               delegate
               {
                   this.ShowToast("startservice_onclick");

                   var intent = new Intent(this, typeof(NotifyService).ToClass());

                   this.startService(intent);
               }
            );
            ll.addView(startservice);
            #endregion

            #region stopservice
            var stopservice = new Button(this);
            stopservice.setText("Stop Service");
            stopservice.AtClick(
                delegate
                {
                    this.ShowToast("stopservice_onclick");

                    Intent intent = new Intent();
                    intent.setAction(NotifyService.ACTION);
                    intent.putExtra("RQS", NotifyService.RQS_STOP_SERVICE);
                    this.sendBroadcast(intent);

                }
            );
            ll.addView(stopservice);
            #endregion

            this.setContentView(sv);

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


        }
        protected override void onCreate(global::android.os.Bundle savedInstanceState)
        {
            // why isnt jsc doing automatic ref?
            var r = default(global::ScriptCoreLib.Android.Windows.Forms.IAssemblyReferenceToken_Forms);
            ScriptCoreLib.Android.ThreadLocalContextReference.CurrentContext = this;

            // X:\jsc.svn\examples\java\android\forms\FormsMessageBox\FormsMessageBox\Library\ApplicationControl.cs

            // cmd /K c:\util\android-sdk-windows\platform-tools\adb.exe logcat
            // Camera PTP

            // http://developer.android.com/guide/topics/ui/notifiers/notifications.html

            base.onCreate(savedInstanceState);

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


            var b = new android.widget.Button(this);

            // jsc is doing the wrong thing here
            //var SDK_INT = android.os.Build.VERSION.SDK_INT;

            //b.setText("Notify! " + new { SDK_INT, android.os.Build.VERSION.SDK });
            b.setText("Notify! " );
            int counter = 0;

            b.AtClick(
                delegate
            {
                counter++;



                var f = new Form1();

                var value = f.ShowDialog();

                b.setText("ShowDialog! " + new { value, f.textBox1.Text });
            }
            );

            ll.addView(b);

            this.setContentView(sv);
        }
        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);


            var b = new Button(this);

            b.setText("Vibrate!");

            b.AtClick(
                delegate
                {
                    var vibrator = (Vibrator)this.getSystemService(Context.VIBRATOR_SERVICE);

                    vibrator.vibrate(600);
                }
            );

            ll.addView(b);





            this.setContentView(sv);


            //this.ShowLongToast("Monese circle progressbar");

            //circularSeekbar = new CircularSeekBar(this);
            //circularSeekbar.setMaxProgress(100);
            //circularSeekbar.setProgress(100);
            //setContentView(circularSeekbar);
            //circularSeekbar.invalidate();

            //circularSeekbar.setSeekBarChangeListener(new TestAndroidCircleProgressbar.Activities.CircularSeekBar.MyOnSeekChangeListener());

        }
        static __InitializeAndroidActivity()
        {
            Console.WriteLine("StaticInvoke");

            //  Exception Ljava/lang/RuntimeException; thrown while initializing LTryHideActionbarExperiment/StaticInvoke;
            try
            {


                // https://groups.google.com/forum/?fromgroups=#!topic/android-developers/suLMCWiG0D8
                var c = ScriptCoreLib.Android.ThreadLocalContextReference.CurrentContext;


                (ScriptCoreLib.Android.ThreadLocalContextReference.CurrentContext as Activity).runOnUiThread(
                    a =>
                    {
                        // http://stackoverflow.com/questions/4451641/change-android-layout-programatically

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

                        var b = new Button(a).AttachTo(ll);



                        b.WithText("before AtClick");
                        b.AtClick(
                            v =>
                            {
                                b.setText("AtClick");
                            }
                        );

                        var b2 = new Button(a);
                        b2.setText("The other button!");
                        ll.addView(b2);

                        a.setContentView(sv);
                    }
                );
            }
            catch (Exception ex)
            {
                Console.WriteLine("error: " + new { ex.Message, ex.StackTrace });
            }
        }
        // http://stackoverflow.com/questions/6274141/trigger-background-service-at-a-specific-time-in-android
        // http://stackoverflow.com/questions/7144908/how-is-an-intent-service-declared-in-the-android-manifest
        // http://developer.android.com/guide/topics/manifest/service-element.html

        //AtBootCompleted hack1;

        protected override void onCreate(global::android.os.Bundle savedInstanceState)
        {
            // http://developer.android.com/guide/topics/ui/notifiers/notifications.html

            base.onCreate(savedInstanceState);

            ScrollView sv = new ScrollView(this);

            LinearLayout ll = new LinearLayout(this);

            ll.setOrientation(LinearLayout.VERTICAL);

            sv.addView(ll);

            var btn = new Button(this);
            btn.setText("wifi");

            ll.addView(btn);

            {
                ConnectivityManager connManager = (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE);
                NetworkInfo wifiNetInfo = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
                NetworkInfo mobileNetInfo = connManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);


                if (wifiNetInfo != null)
                    if (wifiNetInfo.isConnectedOrConnecting())
                    {
                        btn.setText("we are connected via WiFi");
                    }

                if (mobileNetInfo != null)
                    if (mobileNetInfo.isAvailable())
                        if (mobileNetInfo.isConnected())
                        {
                            btn.setText(" we are connected via mobile data (GPRS, 3G, etc.)");
                        }
            }


            this.setContentView(sv);

            this.StartPendingAlarm(typeof(NotifyService), 1000 * 1, 0);


        }
        // http://stackoverflow.com/questions/19954156/android-build-separate-apks-for-different-processor-architectures
        // "X:\jsc.svn\examples\java\android\Test\TestChromeAsAsset\TestChromeAsAsset.sln"

        //  [aapt] W:\bin\AndroidManifest.xml:14: error: Error: No resource found that matches the given name (at 'label' with value '@string/app_name').



        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);

            var b = new Button(this);

            b.setText(
                // X:\jsc.svn\examples\c\android\Test\TestNDKAsAsset\TestNDKAsAsset\Program.cs
                // http://stackoverflow.com/questions/19954156/android-build-separate-apks-for-different-processor-architectures


                //  <package id="TestNDKAsAssetFromSharedLibrary" version="1.0.0.0" targetFramework="net4" userInstalled="true" />
                // X:\jsc.svn\examples\java\android\synergy\OVRVrCubeWorldNativeActivity\OVRVrCubeWorldNativeActivity\ApplicationActivity.cs

                // can we load that native so into a separate process?
                // switch to native and back?
                TestNDKAsAsset.xActivity.stringFromJNI()
            //"Vibrate!"
            );

            b.AtClick(
                delegate
                {
                    var vibrator = (Vibrator)this.getSystemService(Context.VIBRATOR_SERVICE);

                    vibrator.vibrate(600);
                }
            );

            ll.addView(b);



            this.setContentView(sv);


            //this.ShowLongToast("http://my.jsc-solutions.net x");
        }
        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);

            var b = new Button(this).AttachTo(ll);



            b.AtClick(
                v =>
                {
                    b.setText("AtClick");
                }
            );

            //var b2 = new Button(this);
            //b2.setText("The other button!");
            //ll.addView(b2);

            var ipa = Dns.GetHostAddresses(getLocalIpAddress())[0];

            var port = 8080;

            b.WithText(ipa + ":" + port);

            ClassLibrary1.Class1Shared.CreateServer(
                ipa,
                port,
                x =>
                {
                    //b.WithText(x);
                    android.util.Log.wtf("APKWebServer", x);
                }
            ).Start();

            this.setContentView(sv);
        }
        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);

            var b = new Button(this).AttachTo(ll);

            var goo = new foo.Goo();

            //Activator.CreateInstance<

            //var goo = (foo.Goo)Activator.CreateInstance(
            //    typeof(foo.Goo)
            //);

            //E/AndroidRuntime(32112): Caused by: java.lang.RuntimeException
            //E/AndroidRuntime(32112):        at foo.Bar.GetBarString(Bar.java:29)
            //E/AndroidRuntime(32112):        at foo.Goo.GetString(Goo.java:9)
            //E/AndroidRuntime(32112):        at TestJavaNativesOverride.Activities.ApplicationActivity.onCreate(ApplicationActivity.java:69)

            b.WithText(goo.GetString());
            b.AtClick(
                v =>
                {
                    b.setText(
                         new assets::foo.Bar().GetBarString()
                    );
                }
            );


            this.setContentView(sv);



        }
        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);


            var b = new Button(this).AttachTo(ll);

            var uri = new Uri("http://download.jsc-solutions.net/foo/bar.txt?a=1&b=2#frag1/frag2");




            Action<string> w =
                (x) => new Button(this).WithText(x).AttachTo(ll);


            w(
                new
                {
                    uri.OriginalString,
                    uri.Port,
                    uri.Query,
                    uri.PathAndQuery,
                    uri.Fragment,
                    uri.Host
                }.ToString()
            );



            this.setContentView(sv);

            //var foo = new Foo<FooElement>();
            //foo.Invoke(w);
        }
		//		BUILD FAILED
		//x:\util\android-sdk-windows\tools\ant\build.xml:542: Unable to resolve project target 'Google Inc.:Google APIs:21'

		// https://sites.google.com/a/jsc-solutions.net/backlog/knowledge-base/2015/201505/20150503/udp
		// http://www.happygeek.in/programmatically-get-device-imei-in-android


		protected override void onCreate(global::android.os.Bundle savedInstanceState)
		{
			// http://developer.android.com/guide/topics/ui/notifiers/notifications.html

			base.onCreate(savedInstanceState);

			var sv = new ScrollView(this);

			var ll = new LinearLayout(this);

			ll.setOrientation(LinearLayout.VERTICAL);

			sv.addView(ll);


			Button b = new Button(this).WithText("Whats my IMEI?").AtClick(
				delegate
				{
					TelephonyManager telephonyManager = (TelephonyManager)this.getSystemService(Context.TELEPHONY_SERVICE);

					string imei = telephonyManager.getDeviceId();


					this.setTitle(new { imei }.ToString());

					//this.ShowLongToast("IMEI: " + imei);
				}
			);


			ll.addView(b);

			this.setContentView(sv);



		}
		// 3 years later!
        // port from http://www.learnopengles.com/android-lesson-six-an-introduction-to-texture-filtering/
        // Y:\opensource\github\Learn-OpenGLES-Tutorials\android\AndroidOpenGLESLessons\src\com\learnopengles\android\lesson6

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

            //this.ToFullscreen();

            var fl = new FrameLayout(this);
            var ll = new LinearLayout(this);
            
            ll.setHorizontalGravity(Gravity.CENTER_HORIZONTAL);
            ll.setVerticalGravity(Gravity.BOTTOM);

            var button_set_min_filter = new Button(this).AttachTo(ll).WithText("Set min. filter");
            var button_set_mag_filter = new Button(this).AttachTo(ll).WithText("Set mag. filter");

            var v = new RenderingContextView(this).AttachTo(fl);
            var s = new ApplicationSurface(v, button_set_min_filter, button_set_mag_filter, this);

            ll.AttachTo(fl);


            #region density
            var displayMetrics = new DisplayMetrics();
            this.getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);

            v.mDensity = displayMetrics.density;
            #endregion

         

            setContentView(fl);

      


            this.ShowToast("http://my.jsc-solutions.net");
        }
        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);

            {
                var b = new Button(this).AttachTo(ll);
                b.WithText("extras:");
            }

            // http://about-android.blogspot.com/2009/12/passing-data-or-parameter-to-another_02.html

            this.getIntent().With(
                intent =>
                {
                    intent.getExtras().With(
                        e =>
                        {
                            var keys = e.keySet().toArray();
                            foreach (string key in keys)
                            {
                                var b = new Button(this).AttachTo(ll);
                                b.WithText(new { key }.ToString());
                            }

                        }
                    );
                }
            );

            this.setContentView(sv);
        }
Exemplo n.º 26
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);
     
 }
        private void InitializeContent()
        {
            // http://android-developers.blogspot.com/2011/11/new-layout-widgets-space-and-gridlayout.html

            var r = default(global::ScriptCoreLib.Android.Windows.Forms.IAssemblyReferenceToken_Forms);

            var u = new ApplicationControl();

            u.AttachTo(this);

            u.button1.Click += delegate
            {
                //var temp = (__UserControl)(object)u;
                var popupView = new android.widget.LinearLayout(this);
                var dispWidth = getWindowManager().getDefaultDisplay().getWidth() - 60;

                var popupText = new TextView(this);
                popupText.setText("This is Popup Window!");
                popupText.setPadding(0, 0, 0, 20);
                popupText.setTextColor(-16711936);

                var popupFormsTextBox = new TextBox();
                popupFormsTextBox.PasswordChar = '*';
                ((__TextBox)(object)popupFormsTextBox).InternalBeforeSetContext(this);
                var t = ((__TextBox)(object)popupFormsTextBox).InternalGetElement();
                ((EditText)t).setWidth(dispWidth);


                var submitButt = new System.Windows.Forms.Button();
                submitButt.Text = "Submit";
                ((__Button)(object)submitButt).InternalBeforeSetContext(this);
                var b = ((__Button)(object)submitButt).InternalGetElement();

                var cancelButt = new System.Windows.Forms.Button();
                cancelButt.Text = "Cancel";
                ((__Button)(object)cancelButt).InternalBeforeSetContext(this);
                var cb = ((__Button)(object)cancelButt).InternalGetElement();

                popupView.addView(popupText);
                popupView.addView(t);
                popupView.addView(b);
                popupView.addView(cb);

                popupView.setOrientation(1);
                popupView.setBackgroundColor(-3355444);

                var popup = new android.widget.PopupWindow(popupView, dispWidth, 250);
                popup.setContentView(popupView);
                popup.setFocusable(true);
                popup.setOutsideTouchable(true);

                // E/AndroidRuntime( 4979): Caused by: java.lang.NoSuchMethodError: android.widget.PopupWindow.showAsDropDown
                popup.showAsDropDown(((__Button)(object)u.button1).InternalGetElement(), android.view.Gravity.CENTER, 40, 0);
                u.button1.Text = "Now popup must show!!";

                submitButt.Click += delegate
                {
                    submitButt.Text = ((EditText)t).getText().ToString();
                };

                cancelButt.Click += delegate
                {
                    popup.dismiss();
                };
            };



            ////// 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



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

            //[javac] Compiling 527 source files to V:\bin\classes
            //[javac] V:\src\AndroidFormsActivity\ApplicationControl.java:129: error: cannot find symbol
            //[javac]         super.Dispose_06000006(disposing);
            //[javac]              ^
            //[javac]   symbol: method Dispose_06000006(boolean)
            //[javac] Note: V:\src\ScriptCoreLibJava\BCLImplementation\System\Threading\__Thread.java uses or overrides a deprecated API.
        }
        protected override void onCreate(Bundle savedInstanceState)
        {
            var activity = this;
            // http://stackoverflow.com/questions/11425020/actionbar-in-a-dialogfragment
            //To show activity as dialog and dim the background, you need to declare android:theme="@style/PopupTheme" on for the chosen activity on the manifest
            //activity.requestWindowFeature(Window.FEATURE_ACTION_BAR);
            //activity.getWindow().setFlags(WindowManager_LayoutParams.FLAG_DIM_BEHIND, WindowManager_LayoutParams.FLAG_DIM_BEHIND);
            //activity.getWindow().setFlags(WindowManager_LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager_LayoutParams.FLAG_TRANSLUCENT_STATUS);
            //var @params = activity.getWindow().getAttributes();
            ////@params.height = WindowManager_LayoutParams.FILL_PARENT;
            ////@params.width = 850; //fixed width
            ////@params.height = 450; //fixed width
            //@params.alpha = 1.0f;
            //@params.dimAmount = 0.5f;
            //activity.getWindow().setAttributes(@params);
            //activity.getWindow().setLayout(850, 850);
            base.onCreate(savedInstanceState);

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

            var b = new Button(this).AttachTo(ll);


            // https://stackoverflow.com/questions/1898886/removing-an-activity-from-the-history-stack

            b.WithText("start secondary");
            b.AtClick(
                v =>
                {
                    foo = "hi";

                    Intent intent = new Intent(this, typeof(SecondaryActivity).ToClass());
                    intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
                    //intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
                    startActivity(intent);
                }
            );

            this.AtPause += delegate { b.setText("AtPause"); };
            this.AtResume += delegate { b.setText("AtResume"); };


            AtPrepareOptions +=
                value =>
                {
                    value.clear();

                    var item1 = value.add(
                         (java.lang.CharSequence)(object)"http://abstractatech.com"
                    );



                    item1.setIcon(android.R.drawable.ic_menu_view);

                    var item2 = value.add(
                        (java.lang.CharSequence)(object)"http://jsc-solutions.net"
                    );

                    //item2.setIcon(android.R.drawable.ic_menu_edit);
                    item2.setIcon(android.R.drawable.ic_menu_view);

                    var i = new Intent(Intent.ACTION_VIEW,
                        android.net.Uri.parse("http://jsc-solutions.net")
                    );

                    // http://vaibhavsarode.wordpress.com/2012/05/14/creating-our-own-activity-launcher-chooser-dialog-android-launcher-selection-dialog/
                    var ic = Intent.createChooser(i, "http://jsc-solutions.net");


                    item2.setIntent(
                        ic
                    );
                };

            AtOption +=
                item =>
                {

                    //b.WithText("menu was clicked!" + (string)(object)item.getTitle());
                    b.WithText("menu was clicked!" + new { item });
                };

            var b2 = new Button(this);
            b2.setText("The other button!");
            ll.addView(b2);

            this.setContentView(sv);



            vConfigurationChanged = e =>
            {
                var orientation = getScreenOrientation();

                var SystemUiVisibility = getWindow().getDecorView().getSystemUiVisibility();

                b2.setText(
                    new
                    {
                        orientation,
                        SystemUiVisibility
                    }.ToString()
                );


                if (orientation == Configuration.ORIENTATION_LANDSCAPE)
                {
                    hideSystemUI();
                }
                else
                {
                    showSystemUI();
                }
            };

            vConfigurationChanged(null);
        }
        protected override void onCreate(Bundle savedInstanceState)
        {
            // http://www.mkyong.com/android/android-activity-from-one-screen-to-another-screen/

            base.onCreate(savedInstanceState);

            //this.getWindow().getDecorView()
            //this.getWindow().setTitle("secondary " + new { ApplicationActivity.foo});
            //this.getWindow().setTitleColor(0xff0000);

            // Set the IMMERSIVE flag.
            // Set the content to appear under the system bars so that the content
            // doesn't resize when the system bars hide and show.
            getWindow().getDecorView().setSystemUiVisibility(
                    View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                    | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                    | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                    | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar
                    | View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
                    | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);

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

            var b = new Button(this).AttachTo(ll);



            b.WithText(" secondary " + new { ApplicationActivity.foo });
            b.AtClick(
                v =>
                {
                    this.finish();
                }
            );

            //this.AtPause += delegate
            //{
            //    this.finish();
            //};

            //this.AtWindowFocusChanged += e =>
            //    {
            //        if (!e)
            //            this.finish();


            //    };

            //this.AtUserLeaveHint += delegate { this.finish(); };

            //this.onfo
            //this.onWindowFocusChanged
            //public void onWindowFocusChanged (boolean hasFocus)
        }
        // 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");


        }
Exemplo n.º 31
-1
        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);
        }