Blz Pessoal?

Tenho um app com um botão flutuante na tela principal do celular.

Preciso adicionar um evento click para chamar minha classe. Alguém poderia me ajudar?

Segue o código já implementado. (só falta o evento click/tap)...

Obrigado

public class MainActivity : AppCompatActivity
{
private static IWindowManager windowManager;
private static ImageView imageView;
protected override void OnCreate(Bundle savedInstanceState)
{ base.OnCreate(savedInstanceState);
SetContentView(Resource.Layout.activity_main);
if (Android.Provider.Settings.CanDrawOverlays(this))
{
ShowFloatView();
}
else
{
var intent = new Intent(Android.Provider.Settings.ActionManageOverlayPermission);
StartActivityForResult(intent, 0);
}
}
protected override void OnActivityResult(int requestCode, [GeneratedEnum] Result resultCode, Intent data)
{
ShowFloatView();
}
private void ShowFloatView()
{
windowManager
= GetSystemService(WindowService).JavaCast/span>IWindowManager>();
if (imageView != null)
{
windowManager
.RemoveView(imageView);
}
imageView
= new ImageView(Application.Context);
imageView
.SetImageResource(Resource.Drawable.download);
WindowManagerLayoutParams paramsF = new WindowManagerLayoutParams(
WindowManagerLayoutParams.WrapContent,
WindowManagerLayoutParams.WrapContent,
WindowManagerTypes.ApplicationOverlay,
WindowManagerFlags.NotFocusable | WindowManagerFlags.NotTouchModal,
Format.Transparent);
paramsF
.Gravity = GravityFlags.Top | GravityFlags.Left;
paramsF
.X = 0;
paramsF
.Y = 100;
windowManager
.AddView(imageView, paramsF);
}
}

Exibições: 26

© 2018   Criado por Ramon Durães.   Ativado por

Badges  |  Relatar um incidente  |  Termos de serviço