2017-01-14 10 views
5

यह मेरे ऐप के भीतर दिखाए गए अलर्टडियलॉग की एक तस्वीर है। यह को अस्वीकार कर देना चाहिए और एक स्वीकृति बटन होना चाहिए।एंड्रॉइड के तहत गुम संवाद बटन 7.1.1

आप इसे देख सकते हैं नहीं है:

enter image description here

मैं यह त्रुटि पुन: पेश नहीं कर सकते हैं के रूप में मैं न एंड्रॉयड 7.1 के साथ एक फोन है। तस्वीर Google पिक्सेल पर ली गई थी और मुझे भेज दी गई थी।

इस ऐप का परीक्षण करने वाले सभी अन्य एंड्रॉइड संस्करणों पर इस बग का सामना नहीं किया गया था। कोड संवाद के कारण प्रदर्शित करने के लिए

/** 
* Creates a 2 options dialog. 
* @param context 
* @param title headline of the dialog 
* @param message main text of the dialog 
* @param accept listener for the accept button 
* @param deny listener for deny button 
* @param acceptText text of the positive answer button 
* @param denyText text of the negative answer button 
* @param cancelable weather a click to anywhere but the presented buttons dismisses the dialog 
* @return a created dialog instance. To display it call show() 
*/ 
public static AlertDialog createAcceptDenyDialog(Context context, 
               String title, String message, String acceptText, 
               String denyText, boolean cancelable, 
               DialogInterface.OnClickListener accept, 
               DialogInterface.OnClickListener deny, 
               DialogInterface.OnDismissListener dismiss){ 
    AlertDialog.Builder alertDialog = new AlertDialog.Builder(context) 
      .setTitle(title) 
      .setMessage(message) 
      .setPositiveButton(acceptText, accept) 
      .setNegativeButton(denyText, deny) 
      .setCancelable(cancelable) 
      .setOnDismissListener(dismiss); 
    return alertDialog.create(); 
} 

यह है:: (संस्करण 4.1, 6.0.1)

यहाँ विधि संवाद बनाने का कोड है

public void showRequestErrorRetryDialog(String title, String message) { 
    Dialog dialog = DialogFactory.createAcceptDenyDialog(this 
      , title 
      , message 
      , getString(R.string.retry_button) 
      , getString(R.string.abort_button) 
      , true 
      , (dialogInterface, i) -> { 
       onStartServerCommunication(); 
       showProgressOverlay(); 
      } 
      , null 
      , null); 
    dialog.show(); 
} 

आप के रूप में देख सकते हैं, मैं retrolambda का उपयोग करें।

क्या किसी को पता है कि क्या होता है?

+0

शायद आप गलत संदर्भ पारित कर रहे हैं? आपकी विधि में 'यह' क्या है? एंड्रॉइड 7 में मेरे लिए क्या अच्छा काम करता है 'नया अलर्टडिअलॉग.बिल्डर (संदर्भ) .attributes.show() '.. (विशेषताएँ सभी प्रकार हैं।'setTitle()' 'setPositiveButton() 'आदि .. – creativecreatorormaybenot

+0

विधि showRequestErrorRetryDialog को उस गतिविधि के भीतर से बुलाया जाता है जिसमें संवाद दिखाना चाहिए। "यह" गतिविधि – zetain

+0

का संदर्भ है, तो यह गतिविधि तब है? आप getAplicationContext()? – creativecreatorormaybenot

उत्तर

12

समाधान जो मेरे लिए काम कर रहा है मेरी style.xml पर निम्नलिखित लाइनों को जोड़ने के लिए किया गया था:

// your main style 
<style name="YourStyleName" parent="Theme.AppCompat.Light.NoActionBar"> 
    <item name="android:alertDialogTheme">@style/AlertDialogTheme</item> 
    <item name="alertDialogTheme">@style/AlertDialogTheme</item> 
</style> 

// dialog style 
<style name="AlertDialogTheme" parent="Theme.AppCompat.Light.Dialog.Alert"> 
    <item name="colorPrimary">@color/colorPrimary</item> 
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item> 
    <item name="colorAccent">@color/colorAccent</item> 
    <item name="buttonBarButtonStyle">@style/DialogButtonStyle</item> 
</style> 

// button's dialog style 
<style name="DialogButtonStyle" parent="@style/Widget.AppCompat.Button.ButtonBar.AlertDialog"> 
    <item name="android:textColor">@color/colorPrimary</item> 
</style> 

यह पूरी तरह से काम कर रहा है, मुझे आशा है कि यह आप लोग मदद मिलेगी।

संबंधित मुद्दे