ABS Theme.Sherlock.Dialog在GingerBread上显示Dialog Title

时间:2012-10-01 08:11:34

标签: android actionbarsherlock

我的清单中有一个活动定义为android:theme =“Theme.Sherlock.Dialog”。在此对话框的活动的OnCreate函数中,我设置了requestWindowFeature(Window.FEATURE_NO_TITLE);在ICS上,这个工作正常。我得到一个没有标题的对话框,但在GingerBread手机上,Dialog的标题仍然显示为Header蓝线和我的内容。这就是我正在做的事情

<activity
        android:name=".activity.PictureChooserDialog"
        android:configChanges="keyboardHidden|orientation"
        android:label="Set a Picture To Upload"
        android:launchMode="singleTop"
        android:theme="@style/ThemeWithCorners" />


<style name="ThemeWithCorners" parent="Theme.Sherlock.Dialog">
    <item name="android:windowBackground">@drawable/dialog_round_corners</item>
    <item name="android:windowCloseOnTouchOutside">false</item>
</style>


public class PictureChooserDialog extends SherlockActivity {

protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.dialog_picture_chooser_layout);

    //The dialog content

    ((Button) findViewById(R.id.cancelDialog))
            .setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View arg0) {
                    finish();

                }
            });

}

private class CustomClickListener implements ClickListener {

    public void onClick(final int index) {
        switch (index) {
        case 0:
            break;
        case 1:
            break;
        case 2:
            break;
        case 3:
            break;
        }

    }

}
}

1 个答案:

答案 0 :(得分:5)

阅读https://github.com/JakeWharton/ActionBarSherlock/issues/500上的帖子。不得不将android.view.Window更改为com.actionbarsherlock.view.Window。然后setWindowFeature可以工作。