我面临这个奇怪的问题,我创建了一个textview
in activity_main.xml
并将文本设置为:android:text="Oh my god"
But 无论我输入什么文本,应用程序屏幕中的输出都是:
来自 C++ 的你好
In fact, the position of text changes according to my setting but the text always remains unfortunately unchanged. I've tried removing and again adding textview
but no change.
MainActivity.java:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Example of a call to a native method
TextView tv = (TextView) findViewById(R.id.sample_text);
tv.setText(stringFromJNI());
}
活动_main.xml:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TextView
android:id="@+id/sample_text"
android:layout_width="147dp"
android:layout_height="76dp"
android:layout_marginStart="248dp"
android:layout_marginTop="16dp"
android:text="Oh my god"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
PS:有的人也有这样的情况problem https://stackoverflow.com/questions/45837742/android-studio-wrong-file-executed但尚未得到答复。
这是你的问题:
tv.setText(stringFromJNI());
这会将文本设置为任何内容stringFromJNI()
返回,替换您在 XML 中定义的内容。
如果要更改显示的文本,请修改本机方法以返回所需内容、删除编程设置,或更改在代码中设置文本的内容。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)