AVJ
AVJ

Reputation: 154

setTitle of DialogFragment not working in Android M

I am trying to set title to DialogFragment which is working fine in below android M but not in M.

Thanks in advance.

Upvotes: 1

Views: 1127

Answers (2)

Biswas Khayargoli
Biswas Khayargoli

Reputation: 1024

You can also try building your own custom appearance dialog:

new AlertDialog.Builder(new ContextThemeWrapper(Context, R.style.customDialog))
            .setTitle("Title")
            .setMessage("Some message").show();

**In your style:**
<style name="customDialog">
    <item name="android:textColor">@color/txt_color</item>
</style>

**In your colors:**
<color name="txt_color">#ff96f3</color>

Upvotes: 1

Ram Koti
Ram Koti

Reputation: 2211

final AlertDialog diag = new AlertDialog.Builder(this)
    .setTitle("Enter An Administrative Password")
    .setView(R.layout.admin_password_dialog)
    .create();

diag.show();

Button diagButton = (Button) diag.findViewById(R.id.btn_confirmPassword);
diagButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
    // handle button click
    EditText input = (EditText) diag.findViewById(R.id.edit_adminPassword);
    String s = input.getText().toString();
}
});

Upvotes: 1

Related Questions