2015-10-13 62 views
0

爲什麼Snacbar文本無法顯示在已簽名的APK上?這裏是調試APK的代碼。我也啓用了proguard。這是否因爲進步而發生?Android Sncabar文本無法顯示在帶有proguard的已簽名APK上

if (intent.hasExtra(KEY_ERROR_MESSAGE)) { 
    String msg = intent.getStringExtra(KEY_ERROR_MESSAGE); 
    Snackbar snack = Snackbar.make(findViewById(android.R.id.content), msg, Snackbar.LENGTH_LONG); 

    View view = snack.getView(); 
    view.setBackgroundColor(ContextCompat.getColor(SignupActivity.this, R.color.red_EC1C24)); 

    TextView tv = (TextView) view.findViewById(android.support.design.R.id.snackbar_text); 
    tv.setTextColor(ContextCompat.getColor(SignupActivity.this, R.color.accent)); 
    tv.setGravity(Gravity.CENTER_HORIZONTAL); 
    snack.show(); 
    } 

編輯:

intent.hasExtra(KEY_ERROR_MESSAGE)回報trueintent.getStringExtra(KEY_ERROR_MESSAGE)回報null不是預期的String

什麼是ProGuard的規則應該怎麼使用?

+0

沒有你想註釋行4-9和測試您的應用程序? – Amir

+0

並給Snackbar.make()另一個視圖,而不是android.R.id.content – Amir

回答

相關問題