質問

I want to linkify a email address and put a static subject to the email.

In the layout I have this:

<TextView
    android:id="@+id/textView5"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:autoLink="email"
    android:text="@string/email" />

How can I add the subject to the email? I should do this in the Activity with the addLinks() method, am I right? I tried some combinations but the email was being appended to the subject...

I checked those sources but without luck:

役に立ちましたか?

解決

I found a solution:

<TextView
     android:id="@+id/textView5"
     android:layout_width="fill_parent"
     android:layout_height="wrap_content"
     android:gravity="center"
     android:clickable="true"/>

TextView mailTV = (TextView) findViewById(R.id.textView5);
mailTV.setText(Html.fromHtml("<a href=\"mailto:"+getString(R.string.email)+"?subject="+getString(R.string.email_subject)+"\" >"+getString(R.string.email)+"</a>"));
mailTV.setMovementMethod(LinkMovementMethod.getInstance());
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top