You can’t register the onClick
callback(using android:onClick
) for the Button
(from the layout of the Dialog
) in the Fragment
class because Android will not find it as it will search only the Activity
for a method matching that name(Btn_pumpInfo_Clicked
) and it will throw that exception. Instead look for the Button
in the Dialog
and assign it a normal listener:
//...
dialog.setContentView(R.layout.pump_menu)
Button b = (Button) dialog.findViewById(R.id.Button_pumpInfo);
b.setOnClickListener(new OnClickListener() {
@Override
public void onCLick(View v) {
// profit
}
});
Or move the method :
public void Btn_pumpInfo_Clicked(View v) {
// TODO Auto-generated method stub
Toast.makeText(getActivity(), "You clicked on Item 1",
Toast.LENGTH_LONG).show();
}
in the Activity
class if it fits you.