Android 中 TextView 的内部链接?

发布于 2024-09-17 06:11:39 字数 3252 浏览 6 评论 0原文

我发现自己陷入了一些我认为很容易解决的问题中。我的应用程序包含很多 TextView 和 ImageView,其中一个 TextView 包含列出的内容。我希望显示内容的每个元素内部链接到相应的 TextView。可能 TextView 不是正确使用的元素,但我很难找到正确的元素。

内部链接应该像 html 文档中的内部链接一样工作......这可以在 Android 中实现吗?

strings.xml:

<string name="c3">3. Contents</string>
<string name="c4">1. Abstract
\n3. Contents
\n4. List of Abbreviations
\n5. Introduction
\n6. Materials &amp; Methods
\n6.1 Literature Selection
\n6.2 Method
\n6.3 What is Android?
\n6.3.1 Dalvik Virtual Machine and Android Applications
\n6.3.2 Android Structure, Java and XML
\n6.3.3 Android Versions
\n6.4 The Development Environment
\n6.4.1 Android SDK
\n6.4.2 Eclipse IDE
\n6.4.3 Android Virtual Device
\n6.4.4 Secure Digital Card
\n6.5 “Hello World!” as Test of IDE
\n6.6 Test Application
\n6.7 Developing Strategy
\n7. Result
\n7.1 Facebook Connect
\n7.1.1 Facebook Application
\n7.1.2 Facebook Connect for Android
\n7.2 Networking
\n7.3 Data Synchronization
\n8. Discussion
\n9. Conclusion
\n10. References
\n10.1 Internet References
\n10.2 Lecture References\n\n
</string>

main.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@color/smoke"
    android:scrollbars="vertical"
>
    <ScrollView android:id="@+id/ScrollView01"
        android:layout_width="wrap_content" 
        android:layout_height="fill_parent"
        android:scrollbars="none"
    >
        <LinearLayout android:id="@+id/LinearLayout02"
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:paddingLeft="4px"
            android:paddingRight="4px"
        >

        <TextView  
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" 
            android:text="@string/a"
            android:textColor="@color/black"
            android:gravity="center_horizontal"
            android:textSize="16dp"
            android:paddingBottom="2dp"
            android:paddingTop="20dp"
            android:scrollbars="vertical"    
        />
        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" 
            android:text="@string/b"
            android:gravity="center_horizontal"
            android:textColor="@color/black"
            android:scrollbars="vertical"
        />
        <TextView  
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" 
            android:text="@string/c1"
            android:textColor="@color/black"
            android:textSize="20dp"
            android:paddingBottom="2dp"
            android:scrollbars="vertical"
        />
        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" 
            android:text="@string/c2"
            android:textColor="@color/black"
            android:scrollbars="vertical"
         />

I find myself stuck in something I think would be really easy to solve. My app contains a lot of TextViews and ImageViews, and one TextView contains the content listed. I want each element of the displayed content internally linked to the respective TextView. Probably the TextView isn't the right element to use, but I have trouble finding the right element.

The internal link should work exactly like internal links in html-documents... is this possible to achieve in Android?

strings.xml:

<string name="c3">3. Contents</string>
<string name="c4">1. Abstract
\n3. Contents
\n4. List of Abbreviations
\n5. Introduction
\n6. Materials & Methods
\n6.1 Literature Selection
\n6.2 Method
\n6.3 What is Android?
\n6.3.1 Dalvik Virtual Machine and Android Applications
\n6.3.2 Android Structure, Java and XML
\n6.3.3 Android Versions
\n6.4 The Development Environment
\n6.4.1 Android SDK
\n6.4.2 Eclipse IDE
\n6.4.3 Android Virtual Device
\n6.4.4 Secure Digital Card
\n6.5 “Hello World!” as Test of IDE
\n6.6 Test Application
\n6.7 Developing Strategy
\n7. Result
\n7.1 Facebook Connect
\n7.1.1 Facebook Application
\n7.1.2 Facebook Connect for Android
\n7.2 Networking
\n7.3 Data Synchronization
\n8. Discussion
\n9. Conclusion
\n10. References
\n10.1 Internet References
\n10.2 Lecture References\n\n
</string>

main.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@color/smoke"
    android:scrollbars="vertical"
>
    <ScrollView android:id="@+id/ScrollView01"
        android:layout_width="wrap_content" 
        android:layout_height="fill_parent"
        android:scrollbars="none"
    >
        <LinearLayout android:id="@+id/LinearLayout02"
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:paddingLeft="4px"
            android:paddingRight="4px"
        >

        <TextView  
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" 
            android:text="@string/a"
            android:textColor="@color/black"
            android:gravity="center_horizontal"
            android:textSize="16dp"
            android:paddingBottom="2dp"
            android:paddingTop="20dp"
            android:scrollbars="vertical"    
        />
        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" 
            android:text="@string/b"
            android:gravity="center_horizontal"
            android:textColor="@color/black"
            android:scrollbars="vertical"
        />
        <TextView  
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" 
            android:text="@string/c1"
            android:textColor="@color/black"
            android:textSize="20dp"
            android:paddingBottom="2dp"
            android:scrollbars="vertical"
        />
        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" 
            android:text="@string/c2"
            android:textColor="@color/black"
            android:scrollbars="vertical"
         />

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

§普罗旺斯的薰衣草 2024-09-24 06:11:39

如果我是您,我会将您的内容转换为带有内部链接的 HTML,并使用 WebView 来显示它。我不知道你会如何以其他方式完成你想做的事情。此外,这是用于电子书的典型方法,这似乎就是您想要创建的内容。

If I were you, I'd convert your content into HTML with internal links and use a WebView to display it. I have no idea how you would pull off what you are trying to do any other way. Moreover, that's the typical approach used for ebooks, which appears to be what you are trying to create.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文