在 Layout XML 调用字符串资源:

<TextView

    android:layout_width="fill_parent"

    android:layout_height="wrap_content"

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

 

在 Activity 获取字符串资源:

this.getString(R.string.hello);

 

从 Context 获取字符串资源:

context.getString(R.string.hello);

 

从 Application 获取字符串资源:

application.getString(R.string.hello);

// TBKTApplication.getInstance().getString(R.string.api_url)

相关文章:

  • 2021-12-29
  • 2022-01-10
  • 2021-12-23
  • 2022-03-04
  • 2021-09-03
猜你喜欢
  • 2021-06-11
  • 2022-12-23
  • 2022-12-23
  • 2021-07-15
  • 2021-11-17
  • 2021-07-04
  • 2021-10-23
相关资源
相似解决方案