菜鸟学习Android笔记-20140311

来源:互联网 发布:seo编辑工资一般多少 编辑:程序博客网 时间:2024/06/05 08:46

1、编写布局文件时,遇到这样的警告,“[I18N] Hardcoded string "昵称:", should use @string resource”    

原来的代码:

 <TextView         android:id="@+id/username"        android:layout_width="fill_parent"        android:layout_height="wrap_content"        android:text="昵称:"        />

解决办法:

参考地址:http://blog.csdn.net/iqv520/article/details/7579513

在res\values\string.xml中添加以下代码

<string name="UserName">昵称:</string><string name="MobilePhone">手机号:</string><string name="Department">部门</string><string name="PlateNumber">车牌号</string><string name="CarColor">汽车颜色</string><string name="CarModel">车型:</string>

修改后代码:

 <TextView         android:id="@+id/username"        android:layout_width="fill_parent"        android:layout_height="wrap_content"        android:text="@string/UserName"        android:layout_marginTop="20dp"        />



2、警告提示“This text field does not specify an inputType or a hint”

源代码:

 <EditText        android:id="@+id/EntryUsername"          android:layout_width="fill_parent"        android:layout_height="wrap_content"        android:layout_below="@id/username"        android:layout_marginRight="5dp"        />        <requestFocus />

修改后代码:

<EditText        android:id="@+id/EntryUsername"          android:layout_width="fill_parent"        android:layout_height="wrap_content"        android:layout_marginTop="10dp"        android:layout_marginLeft="40dp"        android:hint="@string/message1"        android:inputType="textShortMessage"        android:background="@drawable/rounded_text"/>        <requestFocus />





 

0 0