爱玺玺

爱玺玺的生活日记本。wx:lb87626

android样式文件调用字符串@string/的使用

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"

    xmlns:tools="http://schemas.android.com/tools"

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    android:paddingBottom="@dimen/activity_vertical_margin"

    android:paddingLeft="@dimen/activity_horizontal_margin"

    android:paddingRight="@dimen/activity_horizontal_margin"

    android:paddingTop="@dimen/activity_vertical_margin"

    tools:context="cn.lb.MainActivity" >


    <TextView

        android:id="@+id/textnum"

        android:layout_width="match_parent"

        android:layout_height="wrap_content"

        android:text="@string/ptxt1" />

    <EditText 

        android:id="@+id/editText"

        android:layout_width="match_parent"

        android:layout_height="wrap_content"

        android:layout_below="@id/textnum"

        android:hint="@string/phint"/>

    <Button android:id="@+id/button"

        android:layout_width="match_parent"

        android:layout_height="wrap_content"

        android:text="@string/pbut"/>


</RelativeLayout>



在资源里面有已经存在好的字符串资源用来被上面的样式文件使用

res/values/strings.xml


<?xml version="1.0" encoding="utf-8"?>

<resources>


    <string name="app_name">phonenum</string>

    <string name="hello_world">Hello world!</string>

    <string name="action_settings">Settings</string>

    <string name="ptxt1">请输入电话号码</string>

    <string name="phint">在这里输入电话号码</string>

    <string name="pbut">拨号</string>

</resources>


发表评论:

Powered By Z-BlogPHP 1.4 Deeplue Build 150101

Copyright Your WebSite.Some Rights Reserved.

蜀ICP备11021721号-5