Sherlock Action Bar:findViewById(android.R.id.home)在android 2.3中返回null

时间:2012-08-29 15:15:58

标签: android android-layout

我正在为我的项目使用Sherlock Action Bar。但我面临着问题。我在OnCreate方法中使用此代码。

        ActionBar actionBar = getSupportActionBar();
    actionBar.setHomeButtonEnabled(true);
    actionBar.setDisplayHomeAsUpEnabled(true);
    View iconImage = findViewById(android.R.id.home);
    iconImage.setPadding(100, 0, 0, 0);

在android 4.1中,“iconImage”不为null。但在Android 2.3上。 iconImage始终为null。 你知道为什么吗?你知道如何在android 2.3中获得主页按钮吗? 注意:我检查过,我可以通过实现onOptionsItemSelected方法检测主页按钮单击操作。

请帮助我!

1 个答案:

答案 0 :(得分:3)

“您无法访问主视图,因为它存在于内容视图和窗口装饰”

之上

ActionBarSherlock的作者

查看更多here

P / s:VNese:D