我有一个textview,当我使用tv.setText("hello");
更改文本时,它会更改文本,因为我会检查'Log.d(TAG, tv.getText());'
但是当我运行应用程序时,更改不会直观显示。可能是什么问题?
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getBundleData();
setContentView(R.layout.activity_device_sensor_report);
context = this;
tempN = (TextView) findViewById(R.id.tv_temperature_num);
tempC = (TextView) findViewById(R.id.tv_temperature_cat);
humidityC = (TextView) findViewById(R.id.tv_humidity_cat);
tempN.setText("" + liveDataNum[0]);
humidityC.setText("" + liveDataCat[1]);
Log.d("TAG", ""+humidityC.getText());
drawGraph();
}
XML(非常复杂):
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include
android:id="@+id/main_toolbar"
layout="@layout/toolbar" />
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:id="@+id/sv_liveData">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="0dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:gravity="center"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center">
<TextView
android:id="@+id/tv_temperature_num"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_margin="10dp"
android:background="@drawable/devicecardstatus"
android:gravity="center" />
</LinearLayout>
<TextView
android:id="@+id/tv_temperature_cat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:gravity="center"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center">
<TextView
android:id="@+id/tv_humidity_num"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_margin="10dp"
android:background="@drawable/devicecardstatus"
android:gravity="center"
android:text="00" />
</LinearLayout>
<TextView
android:id="@+id/tv_humidity_cat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:text="Lorem ipsum" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:gravity="center"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center">
<TextView
android:id="@+id/tv_carbonMonoxide_num"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_margin="10dp"
android:background="@drawable/devicecardstatus"
android:gravity="center"
android:text="00" />
</LinearLayout>
<TextView
android:id="@+id/tv_carbonMonoxide_cat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:text="Lorem ipsum" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:gravity="center"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center">
<TextView
android:id="@+id/tv_ozone_num"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_margin="10dp"
android:background="@drawable/devicecardstatus"
android:gravity="center"
android:text="00" />
</LinearLayout>
<TextView
android:id="@+id/tv_ozone_cat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:text="Lorem ipsum" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:gravity="center"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center">
<TextView
android:id="@+id/tv_sulfurDioxide_num"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_margin="10dp"
android:background="@drawable/devicecardstatus"
android:gravity="center"
android:text="00" />
</LinearLayout>
<TextView
android:id="@+id/tv_sulfurDioxide_cat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:text="Lorem ipsum" />
</LinearLayout>
</LinearLayout>
</HorizontalScrollView>
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<include layout="@layout/activity_device_historical_report" />
</ScrollView>
</LinearLayout>
屏幕截图:https://drive.google.com/open?id=0BxkScLxtYNVdZHVnZ2RVS0x2a1k
编辑:我清理/重建,这就是发生的事情:
Error:warning: Ignoring InnerClasses attribute for an anonymous inner class
Error:(org.eclipse.paho.client.mqttv3.persist.MqttDefaultFilePersistence$1) that doesn't come with an
Error:associated EnclosingMethod attribute. This class was probably produced by a
Error:compiler that did not target the modern .class file format. The recommended
Error:solution is to recompile the class from source, using an up-to-date compiler
Error:and without specifying any "-target" type options. The consequence of ignoring
Error:this warning is that reflective operations on this class will incorrectly
Error:indicate that it is *not* an inner class.
Error:warning: Ignoring InnerClasses attribute for an anonymous inner class
Error:(org.eclipse.paho.client.mqttv3.persist.MqttDefaultFilePersistence$2) that doesn't come with an
Error:associated EnclosingMethod attribute. This class was probably produced by a
Error:compiler that did not target the modern .class file format. The recommended
Error:solution is to recompile the class from source, using an up-to-date compiler
Error:and without specifying any "-target" type options. The consequence of ignoring
Error:this warning is that reflective operations on this class will incorrectly
Error:indicate that it is *not* an inner class.