(请忽略汉字)
在我的Android应用程序的调试过程中,我发现无法正确显示TextView之一。它是空白的。我很困惑,无法从Google和Stack中搜索信息,但问题仍然没有解决。
以下是Logcat信息:
07-13 18:53:37.039 20189-21850/system_process W/AlarmManagerService: Unable to set rtc to 1531508017: No such device
07-13 18:53:37.056 20189-20189/system_process D/ConditionProviders.SCP: onReceive android.intent.action.TIME_SET
07-13 18:53:37.065 20189-20189/system_process D/ConditionProviders.SCP: notifyCondition condition://android/schedule?days=6.7&start=23.30&end=10.0&exitAtAlarm=false STATE_FALSE reason=!meetsSchedule
07-13 18:53:37.068 20189-20189/system_process D/ConditionProviders.SCP: notifyCondition condition://android/schedule?days=1.2.3.4.5&start=22.0&end=7.0&exitAtAlarm=false STATE_FALSE reason=!meetsSchedule
07-13 18:53:37.093 20189-20189/system_process D/ConditionProviders.SCP: Scheduling evaluate for Fri Jul 13 22:00:00 GMT+00:00 2018 (1531519200000), in +3h6m22s944ms, now=Fri Jul 13 18:53:37 GMT+00:00 2018 (1531508017056)
07-13 18:53:37.108 20189-20203/system_process I/UsageStatsService: Time changed in UsageStats by 2219 seconds
User[0] Flushing usage stats to disk
07-13 18:53:37.169 20597-20597/com.google.android.deskclock I/AlarmClock: AlarmInitReceiver android.intent.action.TIME_SET
07-13 18:53:37.294 25353-25353/com.androstock.myweatherapp I/InstantRun: starting instant run server: is main process
07-13 18:53:37.363 20295-20526/com.android.systemui D/EGL_emulation: eglMakeCurrent: 0xe65054e0: ver 3 0 (tinfo 0xe65035b0)
07-13 18:53:37.383 20295-20526/com.android.systemui D/EGL_emulation: eglMakeCurrent: 0xe65054e0: ver 3 0 (tinfo 0xe65035b0)
07-13 18:53:37.385 20597-25370/com.google.android.deskclock I/AlarmClock: Removing AlarmClockInfo
07-13 18:53:37.428 20597-20597/com.google.android.deskclock I/DigitalWidgetProvider: onReceive: Intent { act=android.intent.action.TIME_SET flg=0x25200010 cmp=com.google.android.deskclock/com.android.alarmclock.DigitalAppWidgetProvider }
07-13 18:53:37.454 20295-20526/com.android.systemui D/EGL_emulation: eglMakeCurrent: 0xe65054e0: ver 3 0 (tinfo 0xe65035b0)
07-13 18:53:37.490 20295-20526/com.android.systemui I/chatty: uid=10029(com.android.systemui) RenderThread identical 1 line
07-13 18:53:37.516 20295-20526/com.android.systemui D/EGL_emulation: eglMakeCurrent: 0xe65054e0: ver 3 0 (tinfo 0xe65035b0)
07-13 18:53:37.546 20597-20597/com.google.android.deskclock I/DigitalWidgetProvider: onReceive: Intent { act=com.android.deskclock.ALARM_CHANGED flg=0x10 cmp=com.google.android.deskclock/com.android.alarmclock.DigitalAppWidgetProvider }
07-13 18:53:37.571 20189-20203/system_process I/UsageStatsDatabase: Time changed by +36m59s579ms. files deleted: 0 files moved: 16
07-13 18:53:37.588 20189-20203/system_process I/UsageStatsService: User[0] Rollover scheduled @ 2018-07-14 18:53:37(1531594417108)
07-13 18:53:37.745 22241-22425/com.google.android.gms I/Icing: Indexing done 11333953BEE679FDB3FFF479706CDBA63059BB3A
07-13 18:53:38.082 1418-2045/? E/SurfaceFlinger: ro.sf.lcd_density must be defined as a build property
07-13 18:53:38.092 25353-25375/com.androstock.myweatherapp D/OpenGLRenderer: HWUI GL Pipeline
07-13 18:53:38.098 25353-25374/com.androstock.myweatherapp D/NetworkSecurityConfig: No Network Security Config specified, using platform default
07-13 18:53:38.140 25353-25358/com.androstock.myweatherapp I/zygote: Do partial code cache collection, code=7KB, data=16KB
After code cache collection, code=7KB, data=16KB
07-13 18:53:38.141 25353-25358/com.androstock.myweatherapp I/zygote: Increasing code cache capacity to 128KB
07-13 18:53:38.149 25353-25358/com.androstock.myweatherapp I/zygote: Do partial code cache collection, code=7KB, data=34KB
07-13 18:53:38.154 20189-23085/system_process D/WificondControl: Scan result ready event
07-13 18:53:38.153 25353-25358/com.androstock.myweatherapp I/zygote: After code cache collection, code=7KB, data=34KB
07-13 18:53:38.155 25353-25358/com.androstock.myweatherapp I/zygote: Increasing code cache capacity to 256KB
JIT allocated 71KB for compiled code of void android.widget.TextView.<init>(android.content.Context, android.util.AttributeSet, int, int)
Compiler allocated 4MB to compile void android.widget.TextView.<init>(android.content.Context, android.util.AttributeSet, int, int)
07-13 18:53:38.179 1406-14526/? D/gralloc_ranchu: gralloc_alloc: Creating ashmem region of size 8298496
07-13 18:53:38.199 1406-1456/? D/gralloc_ranchu: gralloc_alloc: Creating ashmem region of size 8298496
07-13 18:53:38.206 25353-25375/com.androstock.myweatherapp I/zygote: android::hardware::configstore::V1_0::ISurfaceFlingerConfigs::hasWideColorDisplay retrieved: 0
07-13 18:53:38.206 25353-25375/com.androstock.myweatherapp I/OpenGLRenderer: Initialized EGL, version 1.4
07-13 18:53:38.206 25353-25375/com.androstock.myweatherapp D/OpenGLRenderer: Swap behavior 1
07-13 18:53:38.206 25353-25375/com.androstock.myweatherapp W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
07-13 18:53:38.206 25353-25375/com.androstock.myweatherapp D/OpenGLRenderer: Swap behavior 0
07-13 18:53:38.229 25353-25375/com.androstock.myweatherapp D/EGL_emulation: eglCreateContext: 0xee1e4da0: maj 3 min 0 rcv 3
07-13 18:53:38.230 1406-1456/? D/gralloc_ranchu: gralloc_alloc: Creating ashmem region of size 8298496
07-13 18:53:38.264 25353-25375/com.androstock.myweatherapp D/EGL_emulation: eglMakeCurrent: 0xee1e4da0: ver 3 0 (tinfo 0xee10f7a0)
07-13 18:53:38.274 1418-1492/? E/SurfaceFlinger: ro.sf.lcd_density must be defined as a build property
07-13 18:53:38.375 20189-20207/system_process E/BatteryExternalStatsWorker: modem info is invalid: ModemActivityInfo{ mTimestamp=0 mSleepTimeMs=0 mIdleTimeMs=0 mTxTimeMs[]=[0, 0, 0, 0, 0] mRxTimeMs=0 mEnergyUsed=0}
07-13 18:53:38.385 25353-25375/com.androstock.myweatherapp D/EGL_emulation: eglMakeCurrent: 0xee1e4da0: ver 3 0 (tinfo 0xee10f7a0)
07-13 18:53:38.493 20189-20211/system_process I/ActivityManager: Displayed com.androstock.myweatherapp/.MainActivity: +1s786ms
07-13 18:53:38.540 1418-1418/? W/SurfaceFlinger: couldn't log to binary event log: overflow.
07-13 18:53:38.644 21344-25122/com.google.android.googlequicksearchbox:search I/PBSessionCacheImpl: Deleted sessionId[290192964891] from persistence.
07-13 18:53:38.701 21344-21344/com.google.android.googlequicksearchbox:search W/SearchService: Abort, client detached.
07-13 18:53:38.770 21344-21353/com.google.android.googlequicksearchbox:search E/ReloadingLock: Finalizing LOCKED Token[shortcuts 2018-07-13 18:16:35.002]
以下是相对代码段:
<LinearLayout
android:id="@+id/third_day_forecast"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginTop="10dp"
android:layout_alignParentRight="true"
android:gravity="center_horizontal"
>
<TextView
android:id="@+id/third_day_forecast_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="35sp"
/>
<TextView
android:id="@+id/third_day_forecast_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000"
android:textAppearance="?android:attr/textAppearanceMedium"
/>
<TextView
android:id="@+id/third_day_forecast_temp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000"
android:textAppearance="?android:attr/textAppearanceMedium"
/>
</LinearLayout>
有人知道导致此类错误的原因吗?任何建议可能会有所帮助。提前致谢。
P.s。如果您需要有关我的代码的更多信息,请询问。我是编程的初学者,不知道有人可能需要调试哪些信息。
----------编辑一个----------
MainActivity.java
import android.graphics.Typeface;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.text.Html;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
TextView cityField, detailsField, currentTemperatureField, humidity_field, pressure_field, weatherIcon, updatedField;
TextView firstHourIcon, thirdHourIcon, ninthHourIcon, firstHourText, thirdHourText, ninthHourText;
TextView firstHourTemperature, thirdHourTemperature, ninthHourTemperature;
TextView firstDayIcon, secondDayIcon, thirdDayIcon, firstDayText, secondDayText, thirdDayText;
TextView firstDayTemperature, secondDayTemperature, thirdDayTemperature;
Typeface weatherFont;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getSupportActionBar().hide();
setContentView(R.layout.activity_main);
weatherFont = Typeface.createFromAsset(getApplicationContext().getAssets(), "fonts/weathericons-regular-webfont.ttf");
cityField = (TextView)findViewById(R.id.city_field);
updatedField = (TextView)findViewById(R.id.updated_field);
detailsField = (TextView)findViewById(R.id.details_field);
currentTemperatureField = (TextView)findViewById(R.id.current_temperature_field);
humidity_field = (TextView)findViewById(R.id.humidity_field);
pressure_field = (TextView)findViewById(R.id.pressure_field);
firstHourText = (TextView)findViewById(R.id.first_hour_forecast_text);
thirdHourText = (TextView)findViewById(R.id.third_hour_forecast_text);
ninthHourText = (TextView)yfindViewBId(R.id.ninth_hour_forecast_text);
firstHourTemperature = (TextView)findViewById(R.id.first_hour_forecast_temp);
thirdHourTemperature = (TextView)findViewById(R.id.third_hour_forecast_temp);
ninthHourTemperature = (TextView)findViewById(R.id.ninth_hour_forecast_temp);
firstDayText = (TextView)findViewById(R.id.first_day_forecast_text);
secondDayText = (TextView)findViewById(R.id.second_day_forecast_text);
thirdDayText = (TextView)findViewById(R.id.third_day_forecast_text);
firstDayTemperature = (TextView)findViewById(R.id.first_day_forecast_temp);
secondDayTemperature = (TextView)findViewById(R.id.second_day_forecast_temp);
thirdDayTemperature = (TextView)findViewById(R.id.third_day_forecast_temp);
weatherIcon = (TextView)findViewById(R.id.weather_icon);
weatherIcon.setTypeface(weatherFont);
firstHourIcon = (TextView)findViewById(R.id.first_hour_forecast_icon);
firstHourIcon.setTypeface(weatherFont);
thirdHourIcon = (TextView)findViewById(R.id.third_hour_forecast_icon);
thirdHourIcon.setTypeface(weatherFont);
ninthHourIcon = (TextView)findViewById(R.id.ninth_hour_forecast_icon);
ninthHourIcon.setTypeface(weatherFont);
firstDayIcon = (TextView)findViewById(R.id.first_day_forecast_icon);
firstDayIcon.setTypeface(weatherFont);
secondDayIcon = (TextView)findViewById(R.id.second_day_forecast_icon);
secondDayIcon.setTypeface(weatherFont);
thirdDayIcon = (TextView)findViewById(R.id.third_day_forecast_icon);
thirdDayIcon.setTypeface(weatherFont);
Function.placeIdTask asyncTask =new Function.placeIdTask(new Function.AsyncResponse() {
public void processFinish(String weather_description, String weather_temperature, String weather_humidity, String weather_pressure, String weather_updatedOn, String weather_iconText,
String weather_firstHourIcon, String weather_firstHourText, String weather_firstHourTemperature,
String weather_thirdHourIcon, String weather_thirdHourText, String weather_thirdHourTemperature,
String weather_ninthHourIcon, String weather_ninthHourText, String weather_ninthHourTemperature,
String weather_firstDayIcon, String weather_firstDayText, String weather_firstDayTemperature,
String weather_secondDayIcon, String weather_secondDayText, String weather_secondDayTemperature,
String weather_thirdDayIcon, String weather_thirdDayText, String weather_thirdDayTemperature) {
updatedField.setText(weather_updatedOn);
detailsField.setText(weather_description);
currentTemperatureField.setText(weather_temperature);
humidity_field.setText("Humidity: " + weather_humidity);
pressure_field.setText("Pressure: " + weather_pressure);
firstHourText.setText(weather_firstHourText);
thirdHourText.setText(weather_thirdHourText);
ninthHourText.setText(weather_ninthHourText);
firstHourTemperature.setText(weather_firstHourTemperature);
thirdHourTemperature.setText(weather_thirdHourTemperature);
ninthHourTemperature.setText(weather_ninthHourTemperature);
firstDayText.setText(weather_firstDayText);
secondDayText.setText(weather_secondDayText);
thirdDayText.setText(weather_thirdDayText);
firstDayTemperature.setText(weather_firstDayTemperature);
secondDayTemperature.setText(weather_secondDayTemperature);
thirdDayTemperature.setText(weather_thirdDayTemperature);
weatherIcon.setText(Html.fromHtml(weather_iconText));
firstHourIcon.setText(Html.fromHtml(weather_firstHourIcon));
thirdHourIcon.setText(Html.fromHtml(weather_thirdHourIcon));
ninthHourIcon.setText(Html.fromHtml(weather_ninthHourIcon));
firstDayIcon.setText(Html.fromHtml(weather_firstDayIcon));
secondDayIcon.setText(Html.fromHtml(weather_secondDayIcon));
thirdDayIcon.setText(Html.fromHtml(weather_thirdDayIcon));
}
});
asyncTask.execute(); // asyncTask.execute();
}
}