7

지원 -v7-r18에서 ActionBarCompat를 사용하고 있습니다. 불확실한 진행 상황을 표시하려고하면 Galaxy S3 Android 4.1.2에서 작동하지만 Galaxy Ace Android 2.3.3에서는 작동하지 않습니다.ActionBarCompat를 사용하는 ProgressBar가있는 NullPointerException

나는 이유를 추측 할 수 없다. 예외를 제기

코드 :

@Override 
public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    ... 
    final ActionBarActivity activity = this; 
    content = (WebView) findViewById(R.id.webContent); 
    content.setWebViewClient(new WebViewClient() { 
     @Override 
     public void onPageStarted(WebView view, String url, Bitmap favicon) { 
      super.onPageStarted(view, url, favicon); 
      activity.setSupportProgressBarIndeterminate(true); <=== Line 88 
      activity.setSupportProgressBarIndeterminateVisibility(true); 
     } 
    } 

예외 :

FATAL EXCEPTION: main 
    java.lang.NullPointerException 
    at android.support.v7.app.ActionBarActivityDelegateBase.updateProgressBars(ActionBarActivityDelegateBase.java:508) 
    at android.support.v7.app.ActionBarActivityDelegateBase.setSupportProgressBarIndeterminate(ActionBarActivityDelegateBase.java:469) 
    at android.support.v7.app.ActionBarActivity.setSupportProgressBarIndeterminate(ActionBarActivity.java:282) 
    at MyActivity.onPageStarted(MyActivityActivity.java:88) 
    at android.webkit.CallbackProxy.handleMessage(CallbackProxy.java:266) 
    at android.os.Handler.dispatchMessage(Handler.java:99) 
    at android.os.Looper.loop(Looper.java:123) 
    at android.app.ActivityThread.main(ActivityThread.java:3687) 
    at java.lang.reflect.Method.invokeNative(Native Method) 
    at java.lang.reflect.Method.invoke(Method.java:507) 
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625) 
    at dalvik.system.NativeStart.main(Native Method) 
+1

게시 된 코드에서 88 행을 선택하십시오. –

+0

Oups, 죄송합니다. "activity.setSupportProgressBarIndeterminate (true);"입니다. – JulienC

답변

16

() 메소드 된 setContentView를 호출하기 전에에서 onCreate에 supportRequestWindowFeature(Window.FEATURE_PROGRESS); 또는 supportRequestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); 추가().

+4

좀 더 정확히 말하면, support.News 2.3.3 – JulienC

+0

및'setSupportProgressBarIndeterminateVisibility (Boolean.TRUE); 진행률을 표시하기 위해 두 기능을 모두 추가해야합니다. supportRequestWindowFeature 메소드를 사용하여 진행률과 진행 상황을 모두 요청할 때 – Dori

+2

이 계속 충돌합니다. – JMRboosties

관련 문제