zoukankan      html  css  js  c++  java
  • Android中的动态字符串的处理

     1.效果显示

     2. MainAcitivity.java

     1 package com.example.app2;
     2 
     3 import android.support.v7.app.AppCompatActivity;
     4 import android.os.Bundle;
     5 import android.widget.TextView;
     6 
     7 public class MainActivity extends AppCompatActivity {
     8     private TextView textView;
     9     @Override
    10     protected void onCreate(Bundle savedInstanceState) {
    11         super.onCreate(savedInstanceState);
    12         setContentView(R.layout.activity_main);
    13         textView = (TextView) findViewById(R.id.tv);
    14         String temp = this.getString(R.string.hello);
    15         String result = String.format(temp,"SASS","Android");
    16         textView.setText(result);
    17     }
    18 }

    2.activity_main.xml

     1 <?xml version="1.0" encoding="utf-8"?>
     2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     3     xmlns:tools="http://schemas.android.com/tools"
     4     android:layout_width="match_parent"
     5     android:layout_height="match_parent"
     6     android:paddingBottom="@dimen/activity_vertical_margin"
     7     android:paddingLeft="@dimen/activity_horizontal_margin"
     8     android:paddingRight="@dimen/activity_horizontal_margin"
     9     android:paddingTop="@dimen/activity_vertical_margin"
    10     tools:context="com.example.app2.MainActivity"
    11     android:orientation="vertical">
    12 
    13     <TextView
    14         android:id="@+id/tv"
    15         android:layout_width="wrap_content"
    16         android:layout_height="wrap_content"
    17         />
    18 
    19 </LinearLayout>
  • 相关阅读:
    P2764 最小路径覆盖问题
    P1402 酒店之王 网络流
    P2597 [ZJOI2012]灾难 拓扑排序
    FJOI2017 矩阵填数
    2019.2.27模拟
    2019.2.26模拟
    SDOI2013 方程
    [AH2017/HNOI2017]抛硬币
    Lucas定理和扩展Lucas定理
    LuoguP4861 按钮
  • 原文地址:https://www.cnblogs.com/sunxiaoyan/p/9026438.html
Copyright © 2011-2022 走看看