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!