Is there a ".this" in an Xamarin Android project?

0

I'm rewriting an application that was originally written in Java in Android Studio. Now I am rewriting in C # for the Xamarin Android, so a doubt came to me, in several classes I came across the java type code that:

private void obterWidgets()
        {
            ibtAdicionar = (ImageButton)findViewById(Resource.Id.layout_listview_ibt_adicionar);
            ibtAdicionar.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v)
            {
                Bundle parametros = new Bundle();
                parametros.putInt("RegNumPedido", pedido.getRegNumPedido());
                startActivity(new Intent(PedidoItensGradeActivity.this, MercadoriasGradeActivity.class).putExtras(parametros));
            }
});
        lvItens = (ListView) findViewById(Resource.Id.layout_listview_lv_dados);
tvEmpty = (TextView) findViewById(Resource.Id.layout_listview_tv_empty);
tvEmpty.setText("Nenhum item encontrado");
    }

That in C # looks like this:

private void obterWidgets()
 {
            ibtAdicionar = (ImageButton)findViewById(Resource.Id.layout_listview_ibt_adicionar);
            ibtAdicionar.OnClickListener = new OnClickListenerAnonymousInnerClass(this);
        lvItens = (ListView) findViewById(Resource.Id.layout_listview_lv_dados);
tvEmpty = (TextView) findViewById(Resource.Id.layout_listview_tv_empty);
tvEmpty.Text = "Nenhum item encontrado";
 }

    private class OnClickListenerAnonymousInnerClass : View.OnClickListener
    {
        private readonly MissingClass outerInstance;

        public OnClickListenerAnonymousInnerClass(MissingClass outerInstance)
        {
            this.outerInstance = outerInstance;
        }

        public override void onClick(View v)
        {
            Bundle parametros = new Bundle();
            parametros.putInt("RegNumPedido", pedido.RegNumPedido);
            startActivity((new Intent(PedidoItensGradeActivity.this, typeof(MercadoriasGradeActivity))).putExtras(parametros));
        }
    }

If you notice in the code in C # we will have the anti penultima line:

startActivity((new Intent(PedidoItensGradeActivity.this, typeof(MercadoriasGradeActivity))).putExtras(parametros));

With this .this after the RequestItemsGradActivity causes an error, so if I remove the .this the error disappears, so I wanted to know, is there anything that should replace this .this or is there no need to have it in my code? I'm wondering why the app is not yet ready to be compiled!

    
asked by anonymous 21.06.2018 / 14:06

1 answer

1

It is not necessary to use .this at the end of the class. Either you use the class name or just this . Here's an example of how to start a Activity by passing "parameters" to it.

var activity = new Intent(this, typeof(MercadoriasGradeActivity));
activity.PutExtra("RegNumPedido", pedido.RegNumPedido);
StartActivity(activity);

When looking for this value in MercadoriasGradeActivity , do the following:

string numPedido = Intent.GetStringExtra("RegNumPedido") ?? null;
    
21.06.2018 / 19:51