zoukankan      html  css  js  c++  java
  • 【Android纳米学位】project 0

    1.页面布局

    参考:http://www.xuebuyuan.com/1100763.html

    从不知道如何下手到开始布局出想要的样子,使用线性布局及属性 margin,padding

    2.添加点击事件

    ①   Trying to add setOnClickListener in Button but it is giving error "Cannot resolve symbol 'setOnClickListener'"

    查了一圈资料才知道,犯了一个愚蠢的问题

    Put your button code in the onCreate method. It will work.

    ②  After that , it is giving error "Cannot resolve symbol 'OnClickListener'"

    AndroidStudio中快捷键Alt+Enter,补齐View.OnClickListener(),此问题解决。

    btn2.setOnClickListener( new View.OnClickListener() {}

    3.更换标题栏颜色

    直接上代码:

    定义标题栏的样式

    <resources>
        <style name="title_bg" parent="Android:Theme">
            <item name="android:windowTitleBackgroundStyle">@style/Titleground</item>
        </style>
        <style name="Titleground">  
            <item name="android:background">#ff8f26</item>  
        </style>  
    </resources>

    在manifest中设置样式

     android:theme="@style/title_bg"

    使用上一段代码,一直出错。parent="Android:Theme"时,程序启动即crash。

    后找到另一种方法,修改colorPrimary和colorPrimaryDark值;http://www.cnblogs.com/tianzhijiexian/p/4081562.html

    但实际效果是:只有colorPrimary生效,且标题栏均显示colorPrimary色。后无解。



  • 相关阅读:
    求一个字符串中连续出现次数最多的子串
    LintCode: Longest Common Substring
    LintCode: O(1) Check Power of 2
    LintCode: Fizz Buzz
    LintCode: 3 Sum
    LintCode: Two Sum
    LintCode: Sort Colors
    LintCode: Median of two Sorted Arrays
    LintCode: Search A 2d Matrix
    Lintcode: Sqrt(X)
  • 原文地址:https://www.cnblogs.com/biang/p/6087857.html
Copyright © 2011-2022 走看看