0

SLIDING_CONTENT 参数表示只有Activity滑动时触摸的内容,标题栏停留。

当我导入 ActionbarSherlock 时,我发现它并没有很好地工作。

我看过源代码

这是类 SlidingMenu (attachToActivity) 中代码的一部分

    case SLIDING_CONTENT:
        // take the above view out of
        View content = activity.findViewById(android.R.id.content);
        ViewGroup contentParent = (ViewGroup) content.getParent();
        contentParent.removeView(content);
        contentParent.addView(this, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
        setContent(content);
        // save people from having transparent backgrounds
        if (content.getBackground() == null)
            content.setBackgroundResource(background);
        break;
    }

它适用于包含标题栏的活动,但您知道 abs 自定义标题栏.....

我怎样才能改变一些东西让 SLIDING_CONTENT 活着?多谢!!

4

1 回答 1

0

我解决了这个问题,我有多快~:)

只创建一个新的构造函数

public void attachToActivity(Activity activity, int slideStyle,int id) 

添加一个新的参数 'id' id 代表主要活动布局 id。

然后改变

View content = activity.findViewById(android.R.id.content);

View content  = activity.findViewById(id);

并更改另一个调用旧 attachToActivity 的函数(这很容易)

如果您有任何问题,请给我发电子邮件smallbeardict@163.com

于 2012-12-11T11:10:35.760 回答