i got a java project about floating view from web. i try to translate it to monodroid, but i fail, because on function ,i don't know how to write in monodroid .
java code is in http://www.xsmile.net/file/FloatViewDemo.rar
namespace MonoFloatView
{
[Activity(Label = "MonoFloatView", MainLauncher = true, Icon = "@drawable/icon")]
public class MyFloatViewActivity : Activity
{
private IWindowManager wm = null;
private WindowManagerLayoutParams wmParams = null;
private MyFloatView myFV = null;
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.Main);
createView();
// Create your application here
}
private void createView()
{
//myFV = new MyFloatView(getApplicationContext()); //java
myFV = new MyFloatView(ApplicationContext);
myFV.SetImageResource(Resource.Drawable.Icon);
//wm = (WindowManager)getApplicationContext().getSystemService("window");
//http://stackoverflow.com/questions/13634835/monodroid-screen-dimensions
//i get some tip from url above.
wm = GetSystemService(Activity.WindowService).JavaCast<IWindowManager>();
//i don't know the getApplication, how to write in monodroid?
wmParams = ((MyApplication)getApplication()).getMywmParams();
wmParams.Type = LayoutParams.TYPE_PHONE;
wmParams.Format = PixelFormat.RGBA_8888;
wmParams.Flags = LayoutParams.FLAG_NOT_TOUCH_MODAL
| LayoutParams.FLAG_NOT_FOCUSABLE;
wmParams.Gravity = Gravity.LEFT | Gravity.TOP;
wmParams.X = 0;
wmParams.Y = 0;
wmParams.Width = 40;
wmParams.Height = 40;
wm.AddView(myFV, wmParams);
}
public override void onDestroy()
{
base.OnDestroy();
wm.RemoveView(myFV);
}
}
}