Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/378.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 向文本视图添加多个文本_Java_Android_Android Layout_Android Activity_Parse Platform - Fatal编程技术网

Java 向文本视图添加多个文本

Java 向文本视图添加多个文本,java,android,android-layout,android-activity,parse-platform,Java,Android,Android Layout,Android Activity,Parse Platform,我创建了一个具有类似详细信息的TextView: <TextView android:id="@+id/tAge" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/tHeadline" android:layout_ce

我创建了一个具有类似详细信息的TextView:

 <TextView
            android:id="@+id/tAge"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/tHeadline"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="4dp"
            android:gravity="center" 
            android:hint="Age"
                        android:textSize="18sp"

            android:textColor="#000" />
因此,上面的结果将是Age:Age,它是从Parse生成的

另一个例子

mUserHeadlineRetrieved = (TextView) findViewById(R.id.tHeadline);
mUserAgeRetrieved.setText("Headline:");

                mUserHeadlineRetrieved.setText(objects.get(i).get("Headline")
                        .toString());
因此,上面的结果将是Headline:从解析生成的Headline。 我遇到的问题是,它选择了最后一个setText,而没有将这两个元素结合起来

比如说,我想让他们中的一个像年龄一样大胆:大胆25非大胆

如果您需要任何澄清,请告诉我

mUserAgeRetrieved.setText("Age: " + String.valueOf(objects.get(i).getInt("UserAge")));


您只需要使用常规字符串连接。

当然不需要!setText设置新文本

解决方案非常简单

textView.setText("This: ");
textView.append("works");
textView应该这样说:有效

希望这有帮助


祝您好运:

您可以将两个文本设置为一个字符串,然后进行设置,如下所示:

    mUserAgeRetrieved.setText(Html.fromHtml("<b>" + "Age:" + "</b>" + String.valueOf(objects.get(i).getInt("UserAge"))));

谢谢你的回复。我怎样才能让他们中的一个大胆一点呢?比如说我想要年龄粗体实际agenon粗体OK检查我的编辑,在那里你可以设置它,并把年龄粗体谢谢你的编辑。然而,它似乎将所有内容都加粗,我只希望第一个文本加粗是的,我再次编辑了它。我忘了关闭粗体标记,现在应该可以了。
textView.setText("This: ");
textView.append("works");
    mUserAgeRetrieved.setText(Html.fromHtml("<b>" + "Age:" + "</b>" + String.valueOf(objects.get(i).getInt("UserAge"))));