java 阳光添加虚拟数据
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了java 阳光添加虚拟数据相关的知识,希望对你有一定的参考价值。
package com.example.android.sunshine;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
private TextView mWeatherTextView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_forecast);
/*
* Using findViewById, we get a reference to our TextView from xml. This allows us to
* do things like set the text of the TextView.
*/
mWeatherTextView = (TextView) findViewById(R.id.tv_weather_data);
/*
* This String array contains dummy weather data. Later in the course, we're going to get
* real weather data. For now, we want to get something on the screen as quickly as
* possible, so we'll display this dummy data.
*/
String[] dummyWeatherData = {
"Today, May 17 - Clear - 17°C / 15°C",
"Tomorrow - Cloudy - 19°C / 15°C",
"Thursday - Rainy- 30°C / 11°C",
"Friday - Thunderstorms - 21°C / 9°C",
"Saturday - Thunderstorms - 16°C / 7°C",
"Sunday - Rainy - 16°C / 8°C",
"Monday - Partly Cloudy - 15°C / 10°C",
"Tue, May 24 - Meatballs - 16°C / 18°C",
"Wed, May 25 - Cloudy - 19°C / 15°C",
"Thu, May 26 - Stormy - 30°C / 11°C",
"Fri, May 27 - Hurricane - 21°C / 9°C",
"Sat, May 28 - Meteors - 16°C / 7°C",
"Sun, May 29 - Apocalypse - 16°C / 8°C",
"Mon, May 30 - Post Apocalypse - 15°C / 10°C",
};
for (String dummyWeatherDay : dummyWeatherData) {
mWeatherTextView.append(dummyWeatherDay + "\n\n\n");
}
}
}
以上是关于java 阳光添加虚拟数据的主要内容,如果未能解决你的问题,请参考以下文章
java 阳光防止无效插入
java 阳光偏好片段第2部分
java 阳光AsyncTaskLoader
java 阳光网络2
java 阳光RecyclerView
Java笔记简要总结-类在Java虚拟机中如何玩耍的