【发布时间】:2019-08-05 22:45:27
【问题描述】:
我在 youtube 上尝试了一个教程,但它不起作用,当我单击按钮时没有任何反应。 当我按下按钮时,我想更改布局活动并在新布局上设置一个随机文本,让我们说其他 10 个,在这个当前布局上,我想要一个按钮,它将第一个文本随机更改为另一个。 以下是我用过但没用过的代码。
@我无法添加代码,因为它不允许我将其发布在这里..它说类似无效的内容,但您可以看到图片中的所有内容,所以我完成了所有代码,当我按下时我的按钮它什么也没做,可能是什么问题?如果你有任何想法或者你知道任何教程来帮助我实现我所说的我想做的上部,我将非常感激
@你可以看到有一个字符串选项,当我点击我的按钮时,它应该给我所有的文本,但它没有
sorry for image but it seems like those codes aren't good
<LinearLayout
android:layout_width="332dp"
android:layout_height="184dp"
android:layout_marginStart="36dp"
android:layout_marginLeft="36dp"
android:layout_marginTop="48dp"
android:orientation="vertical"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<Button
android:id="@+id/buttonsports"
android:layout_width="match_parent"
android:layout_height="129dp"
android:background="@drawable/ft"
tools:layout_editor_absoluteX="115dp"
tools:layout_editor_absoluteY="291dp" />
<TextView
android:id="@+id/sports"
android:layout_width="216dp"
android:layout_height="117dp"
android:text="TextView"
tools:layout_editor_absoluteX="95dp"
tools:layout_editor_absoluteY="246dp" />
</LinearLayout>
this is how big my text box is,the "sports" is the id for TextView which is "abc"
【问题讨论】:
-
请编辑您的问题并包含您的代码“不是它的图像”以及更多详细信息,以便更轻松地为您提供帮助
-
更好吗?..
-
我刚刚看到“TextView”正在要求一个字符串,但是那个人没有在他的视频中制作任何内容..这是一个解决方案吗?
-
把教程的链接给我看看和你的代码有什么区别
-
给
LinearLayout's高度和宽度wrap_content并检查此问题是否仍然存在。
标签: android android-layout android-activity onclick android-button