0
I’m rewriting an application that was originally written in Java in Android Studio. Now I’m rewriting in C# for Xamarin Android, so a doubt arose me, in several classes I came across the java code like this:
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");
}
Which in C# looks that way:
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 the code in C# we will have the anti penultimate line:
startActivity((new Intent(PedidoItensGradeActivity.this, typeof(MercadoriasGradeActivity))).putExtras(parametros));
With that . this after the Pedidoitensgradactivity causes an error, so if I remove the . this error disappears, so wanted to know, is there anything that replaces that . this or no need to have it in my code? I am asking because the application is not yet ready to be compiled!
What is
PedidoItensGradeActivity
?– Maniero