Java 将文本链接到段落标题

Java 将文本链接到段落标题,java,android,android-layout,Java,Android,Android Layout,是否可以从文本链接直接链接到段落(可能使用“linkify”) 例如,我有一个包含以下内容的目录: 定义 症状和体征 治疗 等 在同一版面中,我有与这些条目对应的文本或标题。我想点击目录中的文本跳转到我的内容中的特定标题:例如,我点击“体征和症状”,这将直接跳转到内容中标记为“体征和症状”的部分 谢谢 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="htt

是否可以从文本链接直接链接到段落(可能使用“linkify”)

例如,我有一个包含以下内容的目录:

定义 症状和体征 治疗 等 在同一版面中,我有与这些条目对应的文本或标题。我想点击目录中的文本跳转到我的内容中的特定标题:例如,我点击“体征和症状”,这将直接跳转到内容中标记为“体征和症状”的部分

谢谢

<RelativeLayout 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:background="#ffffff"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".Atherosclerosis"
    tools:ignore="UselessParent,ScrollViewCount" >
<ScrollView
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >
    <RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
<LinearLayout
     android:id="@+id/tablecontentlayout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:background="#FAFAD2" >
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="16sp"
        android:textStyle="bold"
        android:textColor="#000000"
        android:text="@string/table" />
     <TextView
         android:id="@+id/definitionid"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="15sp"
        android:textStyle="bold"
        android:textColor="#4682B4"
        android:text="@string/Definition" />
     <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="15sp"
        android:textStyle="bold"
        android:textColor="#4682B4"
        android:text="@string/RiskFactors" />
      <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="15sp"
        android:textStyle="bold"
        android:textColor="#4682B4"
        android:text="@string/Pathophysiology" />
      <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="15sp"
        android:textStyle="bold"
        android:textColor="#4682B4"
        android:text="@string/SignsandSymptoms" />
       <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="15sp"
        android:textStyle="bold"
        android:textColor="#4682B4"
        android:text="@string/Diagnosis" />
       <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="15sp"
        android:textStyle="bold"
        android:textColor="#4682B4"
        android:text="@string/Treatment" />
       <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="15sp"
        android:textStyle="bold"
        android:textColor="#4682B4"
        android:text="@string/Prevention" />
    </LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
    android:layout_height="wrap_content"

    android:layout_below="@+id/tablecontentlayout"
    android:layout_marginTop="15dp"
    android:orientation="vertical" >
        <TextView
            android:id="@+id/atherodefinition" 
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@string/Definition"
            android:background="#F5F5F5"
            android:textColor="#483D8B"
            android:textSize="15sp"
            android:textStyle="bold"/>
        <TextView 
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@string/atherosclerosisdefinition"
            android:textSize="15sp"/>
          <TextView

            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@string/RiskFactors"
            android:background="#F5F5F5"
            android:textColor="#483D8B"
            android:textSize="15sp"
            android:textStyle="bold"/>
        <TextView 
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@string/Modifiable"
            android:textStyle="bold"
            android:textSize="15sp"/>
        <TextView 
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@string/modifiableatherosclerosis"
            android:textSize="15sp"/>
        <TextView 
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@string/Nonmodifiable"
            android:textStyle="bold"
            android:textSize="15sp"/>
        <TextView 
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@string/nonmodifiableatherosclerosis"
            android:textSize="15sp"/>
          <TextView

            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@string/Pathophysiology"
            android:background="#F5F5F5"
            android:textColor="#483D8B"
            android:textSize="15sp"
            android:textStyle="bold"/>
        <TextView 
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@string/pathophysiologyatherosclerosis"
            android:textSize="15sp"/>
        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@string/SignsandSymptoms"
            android:background="#F5F5F5"
            android:textColor="#483D8B"
            android:textSize="15sp"
            android:textStyle="bold"/>
         <TextView 
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@string/atherosclerosissignsandsymptoms"
            android:textSize="15sp"/>
         <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@string/Diagnosis"
            android:background="#F5F5F5"
            android:textColor="#483D8B"
            android:textSize="15sp"
            android:textStyle="bold"/>
         <TextView 
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@string/Diagnosisatherosclerosis"
            android:textSize="15sp"/>
         <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@string/Treatment"
            android:background="#F5F5F5"
            android:textColor="#483D8B"
            android:textSize="15sp"
            android:textStyle="bold"/>
         <TextView 
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@string/treatmentatherosclerosis"
            android:textSize="15sp"/>
         <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@string/Prevention"
            android:background="#F5F5F5"
            android:textColor="#483D8B"
            android:textSize="15sp"
            android:textStyle="bold"/>
         <TextView 
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@string/Preventionatherosclerosis"
            android:textSize="15sp"/>
    </LinearLayout>
    </RelativeLayout>
    </ScrollView>

</RelativeLayout>
我会使用ScrollView的方法

在标题上设置onClick Listener,在onClick方法中,使用获取段落顶部的X坐标,并向下滚动到该位置

例如:

TextView signsAndSymptomsHeader;
ScrollView scrollView;

// do necessary initializations of Views, setup etc ...
// then the following in your onCreate method

signsAndSymptomsHeader.setOnClickListener(new View.OnClickListener(){
    @Override
    onClick(View v){
        switch (v.getId()){
             case R.id.id_of_signs_symptoms_content :
                 scrollView.scrollTo(0,v.getTop());
                 break;
             // repeat for all headers.
        }
    }
});

这是我的java活动是的,看起来你根本没有尝试过我的解决方案。而且,你没有告诉我你对我的建议有什么问题,所以我真的帮不了你。。。
TextView signsAndSymptomsHeader;
ScrollView scrollView;

// do necessary initializations of Views, setup etc ...
// then the following in your onCreate method

signsAndSymptomsHeader.setOnClickListener(new View.OnClickListener(){
    @Override
    onClick(View v){
        switch (v.getId()){
             case R.id.id_of_signs_symptoms_content :
                 scrollView.scrollTo(0,v.getTop());
                 break;
             // repeat for all headers.
        }
    }
});