![](/img/trans.png)
[英]How can I change one of my three buttons colors on click to blue but make it so that only one can be blue at a time?
[英]I have 2 buttons in one activity. When I click on them, I make new intents so I can make a new screen. One works, the other doesn't
我的Java代碼:
Button equations = (Button) findViewById(R.id.algebrabutton);
equations.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Intent myIntent = new Intent(view.getContext(),
algebra_activity.class);
startActivityForResult(myIntent, 0);
}
});
Button word = (Button) findViewById(R.id.wordbutton);
word.setOnClickListener(new View.OnClickListener() {
public void onClick(View view1) {
Intent myIntent1 = new Intent(view1.getContext(),
word_activity.class);
startActivityForResult(myIntent1, 0);
}
});
錯誤日志:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.lawrencej.mathappdeluxe/com.example.lawrencej.mathappdeluxe.algebra_activity}:
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
當我單擊單詞按鈕時,它工作正常並顯示一個新屏幕。 當我單擊方程式按鈕時,應用程序崩潰。 難道我做錯了什么?
在您的styles
代碼中使用它。
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
在你的manifest
<activity
android:name=".algebra_activity"
android:theme="@style/AppTheme.NoActionBar">
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.