小编Jul*_*enC的帖子

使用ActionBarCompat的ProgressBar的NullPointerException

我在support-v7-r18中使用ActionBarCompat.当试图显示不确定的进度时,它适用于Galaxy S3 Android 4.1.2但不适用于Galaxy Ace Android 2.3.3.

我无法理解为什么.

提出异常的代码:

@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);
        }
    }
Run Code Online (Sandbox Code Playgroud)

例外:

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 …
Run Code Online (Sandbox Code Playgroud)

android android-support-library android-actionbar-compat

7
推荐指数
1
解决办法
3315
查看次数

ActionBar Compat在Android 2.3.3上没有显示徽标

我正在尝试使用上一个support-v7 lib中提供的新ActionBar Compat.使用SuppportV7Demos中的示例,当我触摸"DISPLAY_USE_LOGO"时,图标不会改变.

既然我不能在我自己的应用程序中工作,有没有人实现这一点?

ActionBarDisplayOptions.java

package com.example.android.supportv7.app;

public class ActionBarDisplayOptions extends ActionBarActivity
    implements View.OnClickListener, ActionBar.TabListener {
private View mCustomView;
private ActionBar.LayoutParams mCustomViewLayoutParams;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.action_bar_display_options);

    findViewById(R.id.toggle_home_as_up).setOnClickListener(this);
    findViewById(R.id.toggle_show_home).setOnClickListener(this);
    findViewById(R.id.toggle_use_logo).setOnClickListener(this);
    findViewById(R.id.toggle_show_title).setOnClickListener(this);
    findViewById(R.id.toggle_show_custom).setOnClickListener(this);
    findViewById(R.id.toggle_navigation).setOnClickListener(this);
    findViewById(R.id.cycle_custom_gravity).setOnClickListener(this);
    findViewById(R.id.toggle_visibility).setOnClickListener(this);

    // Configure several action bar elements that will be toggled by display options.
    mCustomView = getLayoutInflater().inflate(R.layout.action_bar_display_options_custom, null);
    mCustomViewLayoutParams = new ActionBar.LayoutParams(
            LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);

    final ActionBar bar = getSupportActionBar();
    bar.setCustomView(mCustomView, mCustomViewLayoutParams);
    bar.addTab(bar.newTab().setText("Tab 1").setTabListener(this));
    bar.addTab(bar.newTab().setText("Tab 2").setTabListener(this));
    bar.addTab(bar.newTab().setText("Tab 3").setTabListener(this));
}

@Override
public boolean onCreateOptionsMenu(Menu menu) …
Run Code Online (Sandbox Code Playgroud)

android android-actionbar

5
推荐指数
2
解决办法
4055
查看次数