I am trying to implement a longclick in a graph to set an alarm threshold in there and then the user will be warned if the graph (which reprensents mailboxes) is too important. But my problem comes with long click the normal click is handled but nothing happens when i put the onLong Click here is my code :
@Override
public void onClick(final int index) {
if(index==-1)return;
((MailboxBar)g.getBars().get(index)).getMailboxId();
AlertDialog alertDialog = new AlertDialog.Builder(getActivity()).create() ;
alertDialog.setTitle(g.getBars().get(index).getName());
alertDialog.setMessage("N° de la BAL + Détails");
alertDialog.setIcon(R.drawable.menu_icon);
alertDialog.setButton(DialogInterface.BUTTON_NEGATIVE, getString(R.string.close_dialog), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
alertDialog.show();
}
});
g.isLongClickable();
g.setOnLongClickListener(new BarGraph.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
// TODO Auto-generated method stub
final int index = 0;
((MailboxBar)g.getBars().get(index)).getMailboxId();
Toast.makeText(getActivity(), "Long Clicked", Toast.LENGTH_SHORT).show();
return true;
}
});
g is supposed to be a barGraph where my graph is. Thhank you in advance.