Answer the question
In order to leave comments, you need to log in
How to get checkbox id when using dialog fragment?
How to get checkbox id when using dialog fragment?
here is my class MyDialog
public class MyDialog extends DialogFragment implements View.OnClickListener
{
int idDialog;
final String LOG = "myLogs";
Toast toast;
int level;// уровень игры
int vub; // результат выбора
LayoutInflater inflater;
View rootView;
RadioGroup rg;
Spinner spin;
static MyDialog newInstance(int num) {
MyDialog f = new MyDialog();
// Supply num input as an argument.
Bundle args = new Bundle();
args.putInt("id", num);
f.setArguments(args);
return f;
}
public interface onMyDialigEventListener {
public void someEvent(String s);
}
onMyDialigEventListener categoryEventListener;
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
//this.activity = activity;
setRetainInstance(true);
try {
categoryEventListener = (onMyDialigEventListener) activity;
} catch (ClassCastException e) {
throw new ClassCastException(activity.toString()
+ " must implement onSomeEventListener");
}
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// ставим прозрачный цвет
getDialog().getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
// убираем title из окна
getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
//getDialog().setTitle("Simple Dialog");
idDialog = getArguments().getInt("id");
if(idDialog==1)
{
rootView = inflater.inflate(R.layout.dialog_setting, container, false);
rootView.findViewById(R.id.butok).setOnClickListener(this);
}
return rootView;
}
private RadioButton findViewById(int radioThree) {
// TODO Auto-generated method stub
return null;
}
public void onDismiss(DialogInterface dialog) {
super.onDismiss(dialog);
Log.d(LOG, "Dialog 1: onDismiss");
}
public void onCancel(DialogInterface dialog) {
super.onCancel(dialog);
Log.d(LOG, "Dialog 1: onCancel");
onDismiss(dialog);
//getActivity().finish();
}
@Override
public void onClick(View view) {
String str;
switch (idDialog) {
case 1:
str="SETTING|";
str=str+Integer.toString(level);
categoryEventListener.someEvent(str);
break;
}
dismiss();
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question