我正在尝试重建此库的示例:
https://github.com/umano/AndroidSlidingUpPanel
使用Android Studio 1.5,但是当它到达" setSupportActionBar((工具栏)findViewById(R.id.main_toolbar));"它引发了异常。
public class DemoActivity extends AppCompatActivity {
private static final String TAG = "DemoActivity";
private SlidingUpPanelLayout mLayout;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_demo);
setSupportActionBar((Toolbar) findViewById(R.id.main_toolbar));
异常:
java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.sothree.slidinguppanel/com.sothree.slidinguppanel.demo.
DemoActivity}: java.lang.IllegalStateException:
This Activity already has an action bar supplied by the window decor.
Do not request Window.FEATURE_SUPPORT_ACTION_BAR and set windowActionBar to
false in your theme to use a Toolbar instead.
my styles.xml
<style name="AppBaseTheme" parent="Theme.AppCompat.Light">
<item name="android:windowActionBar">false</item>
<item name="colorPrimary">#ffff9431</item>
<item name="colorPrimaryDark">#ffD56600</item>
我将windowActionBar设置为false。我甚至试图删除它,但它不起作用。
我试过这个帖子但没有成功:
This Activity already has an action bar supplied by the window decor
知道发生了什么事吗?