码迷,mamicode.com
首页 > 移动开发 > 详细

Android中的动态字符串的处理

时间:2018-05-11 23:42:42      阅读:242      评论:0      收藏:0      [点我收藏+]

标签:utf-8   roi   sas   save   main   ppc   ica   sch   instance   

技术分享图片

 

 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>

 

Android中的动态字符串的处理

标签:utf-8   roi   sas   save   main   ppc   ica   sch   instance   

原文地址:https://www.cnblogs.com/sunxiaoyan/p/9026438.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!