简体   繁体   中英

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"/>

and in 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>

I have a custom VerticalTextView . I want to set this text to my Button in xml. How is that done?

A string is a string in the resources and can be used by ANY VIEW this is a BIG HINT .

Explanation

android:text="@layout/active"

Ideally, this should be:

android:text="@string/myText"

Of course myText should be in your strings.xml

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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