i recently switched to AndEngine to play a little bit around with this engine. Before the switch i already implemented a DialogFragment
wich worked just fine. Now i wanted to "port" this DialogFragment
to the AndEngine. Because there is no support for the FragmentActivity (as far as i know) in AndEngine i decided to change my code to a simple Dialog
instead.
Now the dialog opens just fine, but is completely blank. Just a small black rectangle with a border.
I cannot see what could be wrong with my code..maybe you can help.
public class SimpleDialog extends Dialog {
final long number;
Context context;
public SimpleDialog (Context context, long number) {
super(context);
this.number = number;
this.context = context;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
AlertDialog.Builder builder = new AlertDialog.Builder(context);
LayoutInflater inflater = ResourceManager.getInstance().activity.getLayoutInflater();
final View view = inflater.inflate(R.layout.logindialog, null);
final EditText editTextUserName = (EditText) view.findViewById(R.id.usernameToSubmit);
final EditText editTextPassword = (EditText) view.findViewById(R.id.passwordToSubmit);
TextView numberText = (TextView) view.findViewById(R.id.numberText);
highscoreText.setText("Number: " + Long.toString(number));
builder.setView(view)
.setNegativeButton(R.string.login_submit, null)
.setPositiveButton(R.string.login_abort, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dismiss();
}
});
final AlertDialog d = builder.create();
d.setOnShowListener(new DialogInterface.OnShowListener() {
@Override
public void onShow(DialogInterface dialog) {
Button b = d.getButton(AlertDialog.BUTTON_NEGATIVE);
b.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
}
});
}
});
}
This is how i open the Dialog:
ResourceManager.getInstance().activity.runOnUiThread(new Runnable() {
@Override
public void run() {
new SimpleDialog(ResourceManager.getInstance().activity, number).show();
}
});
if you also need my layout please let me know. Thanks a lot!