【问题标题】:Using XML layout for TextView为 TextView 使用 XML 布局
【发布时间】:2014-02-07 15:29:54
【问题描述】:

我使用 Xamarin,我有以下代码:

base.OnCreate (bundle);

TextView textView = new TextView (this.ApplicationContext);
textView.AutoLinkMask = Android.Text.Util.MatchOptions.PhoneNumbers; 
textView.Text = "This is a phone number 0800 32 32 32";

//Linkify.AddLinks(textView, MatchOptions.PhoneNumbers);

SetContentView(textView);

能否请我帮忙做同样的代码,但用资源布局文件代替?

提前致谢

【问题讨论】:

    标签: android layout textview xamarin autolink


    【解决方案1】:

    textview.xml:

    <?xml version="1.0" encoding="utf-8"?>
    <TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/txtView"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="This is a phone number 0800 32 32 32"
    android:autoLink="phone">
    </TextView>
    

    在 onCreate 中只提到

    setContentView(R.layout.textview);
    

    【讨论】:

      【解决方案2】:
      <?xml version="1.0" encoding="utf-8"?>
      <TextView xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/textview"
        android:text="This is a phone number 0800 32 32 32"
        android:autoLink="phone"
      />
      

      【讨论】:

        猜你喜欢
        • 2014-07-17
        • 2011-12-16
        • 1970-01-01
        • 2016-07-28
        • 1970-01-01
        • 2017-08-11
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多