FATAL EXCEPTION: main
Process: com.name.myapplication4.app, PID: 1203
android.util.SuperNotCalledException: Fragment dialog1{b3d62060 #0 dlg1} did not call through to super.onAttach()
package com.shuhermayer.myapplication4.app;
import android.annotation.TargetApi;
import android.app.Activity;
import android.app.DialogFragment;
import android.content.DialogInterface;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.NumberPicker;
import android.widget.TextView;
import android.widget.TimePicker;
import org.w3c.dom.Text;
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public class dialog1 extends DialogFragment implements OnClickListener {
final String LOG_TAG = "myLogs";
String num;
Integer numm;
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
getDialog().setTitle("Title!");
View v = inflater.inflate(R.layout.dialog1, null);
TextView tv= (TextView)v.findViewById(R.id.textView1);
NumberPicker np= (NumberPicker)v.findViewById(R.id.n_p);
v.findViewById(R.id.btnYes).setOnClickListener(this);
v.findViewById(R.id.btnNo).setOnClickListener(this);
v.findViewById(R.id.btnMaybe).setOnClickListener(this);
tv.setText("");
np.setMinValue(50);
np.setMaxValue(100);
num = getArguments().getString("index");
tv.setText(num);
numm=np.getValue();
return v;
}
public static interface OnCompleteListener {
public abstract void onComplete(int time);
}
private OnCompleteListener mListener;
// make sure the Activity implemented it
public void onAttach(Activity activity) {
try {
this.mListener = (OnCompleteListener)activity;
}
catch (final ClassCastException e) {
throw new ClassCastException(activity.toString() + " must implement OnCompleteListener");
}
}
public void onClick(View v) {
Log.d(LOG_TAG, "Dialog 1: " + ((Button) v).getText());
Log.d(LOG_TAG, "numm=np.getValue()="+numm);
mListener.onComplete(numm);
dismiss();
}
public void onDismiss(DialogInterface dialog) {
super.onDismiss(dialog);
Log.d(LOG_TAG, "Dialog 1: onDismiss");
}
public void onCancel(DialogInterface dialog) {
super.onCancel(dialog);
Log.d(LOG_TAG, "Dialog 1: onCancel");
}
}
MainActivity
Dialog1.java