2012-08-07 68 views
1

我使用此代碼從TextView中打開html活動。它工作正常。TextView Html鏈接活動

即點擊'打開活動'它打開活動。

但我的問題是我怎樣才能發送數據或參數?

txtLink = (TextView) findViewById(R.id.txtLink); 

    txtLink.setText(Html 
      .fromHtml("<b>text3:</b> Text with a " 
        + "<a href=\***"com.example.textviewlink:/linkActivty/\">Open Activity</a>*** " 
        + "created in the Java source code using HTML.<a href=\"http://www.google.com\">Google.com</a>")); 
    txtLink.setMovementMethod(LinkMovementMethod.getInstance()); 

如何在上面的代碼中發送額外的參數,以便我可以在目標活動中使用它?

回答

3
String text = "Visit my blog <a href=\"http://sherifandroid.blogspot.com/\">mysite</a> or run the <a href=\"sherif-activity://myactivity?author=sherif&nick=king\">myactivity</a> callback"; 

在被叫活動中使用意圖。

String author = getIntent().getData().getQueryParameter("author"); 
String nick = getIntent().getData().getQueryParameter("nick"); 

看看這個link

-1

例如:

佈局

<TextView 
      android:id="@+id/link_web" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:clickable="true" 
      android:autoLink="web"    
      android:text="@string/link_web"/> 

活動

TextView.setText(Html.fromHtml("http://www.google.com")); 
+0

的問題不是關於鏈接到谷歌的網站。這是關於一個活動的鏈接。 – 2014-02-18 05:52:28