繁体   English   中英

如何在Android中为按钮设置自定义文本?

[英]How to set custom text for a button in Android?

<Button android:id="@+id/AdultLeft1"
     android:layout_width="40dip" android:text="@layout/active"
     android:layout_marginTop="110dip" android:layout_height="wrap_content"
     android:background="@drawable/notselectedtabright_landscape"
     android:focusable="false"/>

并在active.xml

<?xml version="1.0" encoding="UTF-8"?>
     <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:orientation="vertical"android:layout_width="fill_parent"
     android:layout_height="wrap_content">
          <com.xxx.VerticalTextView
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          android:textColor="@color/black"
          android:textStyle="bold"android:textSize="12dip"
          android:text="Closed\nCases"/>

</RelativeLayout>

我有一个自定义VerticalTextView 我想将此文本设置为xml中的Button。 怎么做?

字符串是资源中的字符串, 任何视图都可以使用,这是一个大提示

说明

android:text="@layout/active"

理想情况下,应为:

android:text="@string/myText"

当然myText应该在您的strings.xml中

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM