.xml使用方法

一、在程序中获取string.xml中字符串和数值



    Hello World,MainActivity!
    TestExample01


1.在Activity中使用:

StringappName=(String) this.getResources().getText(R.string.app_name);
Log.i("test", "appName="+appName);

或者:   
String appName=(String) this.getResources().getString(R.string.app_name);
Log.i("test", "appName="+appName);


2.我经常在activity_main

   

        android:id="@+id/textviewnumber"

        android:layout_width="fill_parent"

        android:layout_height="wrap_content"

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



你可能感兴趣的:(Android)