Tecnologia do Blogger.
RSS

[androidbrasil-dev] Problema com menu de contexto

Ele exibe perfeitamente o menu de contexto, mas não reconhece quando eu clico no item. Não acontece nada, como se não tivesse chamado o metodo onContextItemSelected();
package pizzaria.lafornalha.fragment.dialog;

import pizzaria.lafornalha.R;
import pizzaria.lafornalha.activity.CardapioActivity;
import pizzaria.lafornalha.modelo.adapter.PedidosAdapter;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.LayoutInflater;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

public class PedidosDialog extends DialogFragment implements OnClickListener {

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.dialog_pedidos, container);

getDialog().getWindow().requestFeature(STYLE_NO_TITLE);

ListView listview = (ListView) v.findViewById(R.id.listview_pedidos);
listview.setAdapter(new PedidosAdapter(CardapioActivity.pedidos,
getActivity()));
registerForContextMenu(listview);

Button botao = (Button) v.findViewById(R.id.botao_pedir_dialog);
TextView valor = (TextView) v.findViewById(R.id.valor_total_pedido);

botao.setOnClickListener(this);

return v;

}

@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub

}

@Override
public void onCreateContextMenu(ContextMenu menu, View v,
ContextMenuInfo menuInfo) {
MenuInflater inflater = getActivity().getMenuInflater();
inflater.inflate(R.menu.menu_contexto_pedido, menu);
}

@Override
public boolean onContextItemSelected(MenuItem item) {
AdapterContextMenuInfo info = (AdapterContextMenuInfo) item
.getMenuInfo();
Toast.makeText(getActivity(), "Menu de Contexto Clicado",
Toast.LENGTH_SHORT).show();
return true;
}
}


O que será que pode ser?

--
You received this message because you are subscribed to the Google Groups "Android Brasil - Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to androidbrasil-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • RSS

0 comentários:

Postar um comentário