문제

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