2012-04-01 1 views
-1

Ich bekomme eine E-Mail von PHP-Skript Echo. Und ich lade das in Textansicht in einer Android-Anwendung. Es wird gerade als Text angezeigt. Wie kann ich es als einen Hyperlink anzeigen, so dass ich darauf klicken kann, um zu E-Mail zu gehen?Android - Hyper Link-Anzeige

package com.example.login2; 

import java.util.ArrayList; 

import org.apache.http.NameValuePair; 
import org.apache.http.message.BasicNameValuePair; 

import android.app.Activity; 
import android.content.Intent; 
import android.os.Bundle; 
import android.widget.Button; 
import android.widget.TextView; 


public class SAppointmentActivity extends Activity { 
    TextView news; 

    @Override 
    protected void onCreate(Bundle savedInstanceState1) { 
     // TODO Auto-generated method stub 
     super.onCreate(savedInstanceState1); 
     setContentView(R.layout.snews); 
     news = (TextView)findViewById(R.id.news); 
     news.setText("Hello"); 

     ArrayList<NameValuePair> postParameters = new ArrayList<NameValuePair>(); 
     MyApp MyAppVar = new MyApp(); 
     postParameters.add(new BasicNameValuePair("username", MyAppVar.getName())); 
     postParameters.add(new BasicNameValuePair("password", MyAppVar.getPasswd())); 

     //String valid = "1"; 
     String response = null; 
     try { 
      response = CustomHttpClient.executeHttpPost("http://192.168.1.8/appointment.php", postParameters); 
      String res=response.toString(); 
      // res = res.trim(); 
      //res= res.replaceAll("\\s+",""); 
      news.setText(res); 
     } 
     catch (Exception e) { 
      news.setText("Error"); 
     } 
    } 
} 

Antwort

1
TextView email = (TextView)findViewById(R.id.TextView04); 
email.setText("sadasd [email protected]"); 
email.setLinkTextColor(Color.WHITE); 
Linkify.addLinks(email,Linkify.EMAIL_ADDRESSES); 

Dies ist der Arbeitscode. Probier es einfach.

1
Linkify.addLinks(news, Linkify.EMAIL_ADDRESSES);