2016-04-26 14 views
1

私のグラフィックレイアウトでは、テキストが多く、最後にハイパーリンクがあります。テキストがレイアウトに完全に収まらないため、スクロールビューが追加されました。エミュレータを起動すると、表示されるのはハイパーリンクだけです。テキストはまったくありません。私は私のプロジェクトの実行時に enter image description hereテキストがエミュレータに表示されていない、グラフィックレイアウト内の場所

これは、次のとおりです:

この

は、私は私のプロジェクトを実行する前に、私は私のグラフィックレイアウトで見たものである

package com.example.rodekruis; 
import android.net.Uri; 
import android.os.Bundle; 
import android.app.Activity; 
import android.content.Intent; 
import android.text.Html; 
import android.text.Spanned; 
import android.text.method.LinkMovementMethod; 
import android.view.Menu; 
import android.view.MenuItem; 
import android.view.View; 
import android.widget.AdapterView; 
import android.widget.Button; 
import android.widget.TextView; 

public class BWCActivity extends Activity { 


    TextView HyperLink; 
    Spanned Text; 
    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_bwc); 

     TextView textView =(TextView)findViewById(R.id.textView); 
     textView.setClickable(true); 
     textView.setMovementMethod(LinkMovementMethod.getInstance()); 
     String text = "<a href='https://www.rkz.nl/het_kinderbrandwondencentrum'> Kinderbrandwondencentrum </a>"; 
     textView.setText(Html.fromHtml(text)); 

    } 

} 
:ここ enter image description here

を私のメインの活動のコードがあります

これは私のactivity_mainコードです:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" 
    tools:context="com.example.rodekruis.Bezoek" > 



    <ImageView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginBottom="20dp" 
     android:src="@drawable/rkz_logo" 
     android:layout_gravity="left" 
     android:layout_marginLeft="38dp"/> 


    <ScrollView 
     android:id="@+id/scrollview" 
     android:layout_width="fill_parent" 
     android:layout_height="364dp" > 


    <TextView 
     android:id="@+id/textView" 
     android:layout_width="244dp" 
     android:layout_height="276dp" 
     android:layout_gravity="center" 
     android:text="@string/title_activity_bwc" 
     android:textAppearance="?android:attr/textAppearanceSmall" 
     android:textColor="@color/black" /> 


</ScrollView> 
</LinearLayout> 
テキストが既にリンクの使用が含まれている場合

答えて

0

は、あなただけのTextView

String text = "<a href='https://www.rkz.nl/het_kinderbrandwondencentrum'> Kinderbrandwondencentrum </a>"; 
textView.setText(Html.fromHtml(text)); 

内のリンクを設定し、この:

String text = getResources().getString(R.string.title_activity_bwc); 
textView.setText(Html.fromHtml(text)); 

をそれとも、リンクの使用を追加したい場合は、この:

String text = getResources().getString(R.string.title_activity_bwc); 
text += "<a href='https://www.rkz.nl/het_kinderbrandwondencentrum'> Kinderbrandwondencentrum </a>"; 
textView.setText(Html.fromHtml(text)); 
+0

私の主な活動にはすでにこのコードがあります。これは、私はそれの上に他の3行を削除する必要がありますか? –

+0

'textView.setText(Html.fromHtml(text));' 'xml'で設定したテキストを削除する – Exaqt

+0

私は下のものを使っていますが、今度はテキストが表示されますが、テキストの最後の単語Kinderbrandwondencentrumは、ハイパーリンクではなく、単なる普通の単語です。 –

関連する問題