当前位置: 首页>>代码示例>>Java>>正文


Java ScrollView.setVisibility方法代码示例

本文整理汇总了Java中android.widget.ScrollView.setVisibility方法的典型用法代码示例。如果您正苦于以下问题:Java ScrollView.setVisibility方法的具体用法?Java ScrollView.setVisibility怎么用?Java ScrollView.setVisibility使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.widget.ScrollView的用法示例。


在下文中一共展示了ScrollView.setVisibility方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCreate

import android.widget.ScrollView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_weather);

    /*1. initialize the whole widget*/
    // the upper part
    titleCity = (TextView) findViewById(R.id.title_city);
    degreeText = (TextView) findViewById(R.id.degree_text);
    weatherLayout = (ScrollView) findViewById(R.id.weather_layout);
    weatherInfoText = (TextView) findViewById(R.id.weather_info_text);
    titleUpdateTime = (TextView) findViewById(R.id.title_update_time);
    // the lower part
    aqiText = (TextView) findViewById(R.id.aqi_text);
    pm25Text = (TextView) findViewById(R.id.pm25_text);
    sportText = (TextView) findViewById(R.id.sport_text);
    comfortText = (TextView) findViewById(R.id.comfort_text);
    carWashText = (TextView) findViewById(R.id.car_wash_text);
    forecastLayout = (LinearLayout) findViewById(R.id.forecast_layout);

    /*2.query the data of weather*/
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
    String weatherString = preferences.getString("weather", null);

    if (weatherString != null) {  // have local cache
        Weather weather = Utility.handleWeatherResponse(weatherString);
        showWeatherInfo(weather);
    }
    else { // have no local cache
        String weatherID = getIntent().getStringExtra("weather_id");
        weatherLayout.setVisibility(View.INVISIBLE);
        requestWeather(weatherID);
    }
}
 
开发者ID:ValueYouth,项目名称:time-weather,代码行数:35,代码来源:WeatherActivity.java

示例2: onCreate

import android.widget.ScrollView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (Build.VERSION.SDK_INT >= 21) {
        View decorView = getWindow().getDecorView();
        decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
        getWindow().setStatusBarColor(Color.TRANSPARENT);
    }
    setContentView(R.layout.activity_weather);
    //初始化各控件
    bingPicImg = (ImageView) findViewById(R.id.bing_pic_img);
    weatherLayout = (ScrollView) findViewById(R.id.weather_layout);
    titleCity = (TextView) findViewById(R.id.title_city);
    titleUpdateTime = (TextView) findViewById(R.id.title_update_time);
    degreeText = (TextView) findViewById(R.id.degree_text);
    weatherInfoText = (TextView) findViewById(R.id.weather_info_text);
    forecastLayout = (LinearLayout) findViewById(R.id.forecast_layout);
    apiText = (TextView) findViewById(R.id.api_text);
    pm25Text = (TextView) findViewById(R.id.pm25_text);
    comfortText = (TextView) findViewById(R.id.comfort_text);
    carWashText = (TextView) findViewById(R.id.car_wash_text);
    sportText = (TextView) findViewById(R.id.sport_text);
    drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    navButton = (Button) findViewById(R.id.nav_button);
    swipeRefresh = (SwipeRefreshLayout) findViewById(R.id.swipe_refresh);
    swipeRefresh.setColorSchemeResources(R.color.colorPrimary);
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
    String weatherString = prefs.getString("weather", null);
    if (weatherString != null) {
        //有缓存时直接解析天气数据
        Weather weather = Utility.handleWeatherResponse(weatherString);
        mWeatherId = weather.basic.weatherId;
        showWeatherInfo(weather);
    } else {
        //无缓存时去服务器查询天气
        mWeatherId = getIntent().getStringExtra("weather_id");
        weatherLayout.setVisibility(View.INVISIBLE);
        requestWeather(mWeatherId);
    }
    swipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            requestWeather(mWeatherId);
            loadBingPic();
        }
    });
    String bingPic = prefs.getString("bing_pic", null);
    if (bingPic != null) {
        Glide.with(this).load(bingPic).into(bingPicImg);
    } else {
        loadBingPic();
    }
    navButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            drawerLayout.openDrawer(GravityCompat.START);
        }
    });
}
 
开发者ID:Qinlong275,项目名称:AndroidBookTest,代码行数:60,代码来源:WeatherActivity.java

示例3: onCreate

import android.widget.ScrollView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (Build.VERSION.SDK_INT >= 21) {
        View decorView = getWindow().getDecorView();
        decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
        getWindow().setStatusBarColor(Color.TRANSPARENT);
    }

    setContentView(R.layout.activity_weather);
    weatherLayout = (ScrollView) findViewById(R.id.weather_layout);
    titleCity = (TextView) findViewById(R.id.title_city);
    titleUpdateTime = (TextView) findViewById(R.id.title_ypdate_time);
    degreeText = (TextView)findViewById(R.id.degree_text);
    weatherInfoText = (TextView) findViewById(R.id.weather_info_text);
    forecastLayout = (LinearLayout) findViewById(R.id.forecast_layout);
    aqiText = (TextView) findViewById(R.id.aqi_text);
    pm25Text = (TextView) findViewById(R.id.pm25_text);
    comfortText = (TextView) findViewById(R.id.comfort_text);
    carWashText = (TextView) findViewById(R.id.car_wash_text);
    sportText = (TextView) findViewById(R.id.sport_text);
    bingPicImage = (ImageView) findViewById(R.id.bing_pic_img);

    swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_refresh);
    swipeRefreshLayout.setColorSchemeResources(R.color.colorPrimary);

    drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    navButton = (Button) findViewById(R.id.nav_button);
    navButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            drawerLayout.openDrawer(GravityCompat.START);
        }
    });

    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
    String weatherString = preferences.getString("weather", null);
    if (weatherString != null) {
        Weather weather = Utility.handleWeatherResponse(weatherString);
        mWeatherId = weather.basic.weatherId;
        showWeatherInfo(weather);
    } else {
        mWeatherId = getIntent().getStringExtra("weather_id");
        weatherLayout.setVisibility(View.INVISIBLE);
        requestWeather(mWeatherId);
    }
    String bingPic = preferences.getString("bing_pic", null);
    if (bingPic != null) {
        Glide.with(this).load(bingPic).into(bingPicImage);
    } else {
        loadBingPic();
    }

    swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            requestWeather(mWeatherId);
        }
    });
}
 
开发者ID:jiangboLee,项目名称:coolWeather,代码行数:62,代码来源:WeatherAcitivity.java

示例4: onCreate

import android.widget.ScrollView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_weather);
    //初始化控件
    swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_refresh);
    drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    navButton = (Button) findViewById(R.id.nav_button);
    weatherLayout = (ScrollView) findViewById(R.id.weather_layout);
    titleCity = (TextView) findViewById(R.id.title_city);
    titleUpdateTime = (TextView) findViewById(R.id.title_update_time);
    templateText = (TextView) findViewById(R.id.template_text);
    feellikeText = (TextView) findViewById(R.id.feellike_text);
    codeImage = (ImageView) findViewById(R.id.code_image);
    weatherTxtText = (TextView) findViewById(R.id.weather_txt_text);
    moreLayout = (LinearLayout) findViewById(R.id.more_layout);
    humText = (TextView) findViewById(R.id.hum_text);
    windDirText = (TextView) findViewById(R.id.wind_dir_text);
    windScText = (TextView) findViewById(R.id.wind_sc_text);
    visText = (TextView) findViewById(R.id.vis_text);

    swipeRefreshLayout.setColorSchemeResources(R.color.colorAccent);

    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
    String weatherString = preferences.getString("weather", null);

    if (weatherString != null) {
        //有缓存的时候直接解析天气数据
        Weather weather = Utility.handleWeatherResponse(weatherString);
        mWeatherId = weather.basic.weatherId;
        showWeatherInfo(weather);
    } else {
        //无缓存的时候去服务器查询天气
        mWeatherId = getIntent().getStringExtra("weather_id_kipmin");
        weatherLayout.setVisibility(View.INVISIBLE);
        requestWeather(mWeatherId);
    }

    swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            requestWeather(mWeatherId);
        }
    });

    navButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            drawerLayout.openDrawer(GravityCompat.START);
        }
    });
}
 
开发者ID:kipmin,项目名称:KipminWeather,代码行数:53,代码来源:WeatherActivity.java

示例5: createLayout

import android.widget.ScrollView; //导入方法依赖的package包/类
private void createLayout(int width) {
    float scale = IceScreenUtils.densityScale(getApplicationContext());
    int margin = 16 * Math.round(scale);

    LinearLayout.LayoutParams baseParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    LinearLayout.LayoutParams containerParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    LinearLayout.LayoutParams imageParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT, 1f);

    ScrollView baseScroller = new ScrollView(this);
    baseScroller.setLayoutParams(baseParams);
    baseScroller.setBackgroundColor(0xffffffff);
    setContentView(baseScroller);
    baseScroller.setVisibility(View.VISIBLE);

    // display width hack
    Rect windowRect = new Rect();
    baseScroller.getWindowVisibleDisplayFrame(windowRect);
    int windowWidth = windowRect.right - windowRect.left;

    LinearLayout baseLayout = new LinearLayout(this);
    baseLayout.setOrientation(LinearLayout.VERTICAL);
    baseLayout.setLayoutParams(layoutParams);
    baseLayout.setPadding(margin, margin, 0, 0);
    baseScroller.addView(baseLayout);

    String[] wallpapers = getResources().getStringArray(R.array.wallpapers);
    for (int i = 0; i < wallpapers.length; i++) {
        if ((i % width) == 0) {
            layoutList.add((i / width), new LinearLayout(this));
            layoutList.get(i / width).setOrientation(LinearLayout.HORIZONTAL);
            layoutList.get(i / width).setGravity(Gravity.LEFT);
            layoutList.get(i / width).setLayoutParams(containerParams);

            baseLayout.addView(layoutList.get(i / width));
        }
        imageList.add(i, new ImageView(this));
        imageList.get(i).setLayoutParams(imageParams);
        imageList.get(i).setScaleType(ImageView.ScaleType.FIT_XY);
        imageList.get(i).setPadding(0, 0, margin, margin);
        IceImageUtils.bitmapLoadAsync(imageList.get(i), getApplicationContext(), getApplicationContext().getResources(), wallpapers[i], (windowWidth / width) - (margin * width + margin) / width, (windowWidth / width) - (margin * width + margin) / width);
        imageList.get(i).setAdjustViewBounds(true);

        final Integer tempId = getResources().getIdentifier(wallpapers[i], "drawable", getPackageName());
        imageList.get(i).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                wallpaperView(tempId);
            }
        });

        layoutList.get(i / width).addView(imageList.get(i));
    }
}
 
开发者ID:dkanada,项目名称:frost,代码行数:55,代码来源:WallpaperActivity.java

示例6: createLayout

import android.widget.ScrollView; //导入方法依赖的package包/类
private void createLayout(int width) {
    float scale = IceScreenUtils.densityScale(getApplicationContext());
    int margin = 16 * Math.round(scale);

    LinearLayout.LayoutParams baseParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    LinearLayout.LayoutParams containerParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    LinearLayout.LayoutParams imageParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT, 1f);

    ScrollView baseScroller = new ScrollView(this);
    baseScroller.setLayoutParams(baseParams);
    baseScroller.setBackgroundColor(0xff000000);
    setContentView(baseScroller);
    baseScroller.setVisibility(View.VISIBLE);

    // display width hack
    Rect windowRect = new Rect();
    baseScroller.getWindowVisibleDisplayFrame(windowRect);
    int windowWidth = windowRect.right - windowRect.left;

    LinearLayout baseLayout = new LinearLayout(this);
    baseLayout.setOrientation(LinearLayout.VERTICAL);
    baseLayout.setLayoutParams(layoutParams);
    baseLayout.setPadding(margin, margin, 0, 0);
    baseScroller.addView(baseLayout);

    String[] images = getResources().getStringArray(R.array.icon_pack);
    for (int i = 0; i < images.length; i++) {
        if ((i % width) == 0) {
            layoutList.add((i / width), new LinearLayout(this));
            layoutList.get(i / width).setOrientation(LinearLayout.HORIZONTAL);
            layoutList.get(i / width).setGravity(Gravity.LEFT);
            layoutList.get(i / width).setLayoutParams(containerParams);

            baseLayout.addView(layoutList.get(i / width));
        }
        imageList.add(i, new ImageView(this));
        imageList.get(i).setLayoutParams(imageParams);
        imageList.get(i).setScaleType(ImageView.ScaleType.FIT_XY);
        imageList.get(i).setPadding(0, 0, margin, margin);
        IceImageUtils.bitmapLoadAsync(imageList.get(i), getApplicationContext(), getApplicationContext().getResources(), "nodpi_" + images[i], (windowWidth / width) - (margin * width + margin) / width, (windowWidth / width) - (margin * width + margin) / width);
        imageList.get(i).setAdjustViewBounds(true);
        layoutList.get(i / width).addView(imageList.get(i));
    }
}
 
开发者ID:dkanada,项目名称:frost,代码行数:46,代码来源:IconActivity.java

示例7: onCreate

import android.widget.ScrollView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (Build.VERSION.SDK_INT >= 21) {
        View decorView = getWindow().getDecorView();
        decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
        getWindow().setStatusBarColor(Color.TRANSPARENT);
    }
    setContentView(R.layout.activity_weather);
    // 初始化各控件
    bingPicImg = (ImageView) findViewById(R.id.bing_pic_img);
    weatherLayout = (ScrollView) findViewById(R.id.weather_layout);
    titleCity = (TextView) findViewById(R.id.title_city);
    titleUpdateTime = (TextView) findViewById(R.id.title_update_time);
    degreeText = (TextView) findViewById(R.id.degree_text);
    weatherInfoText = (TextView) findViewById(R.id.weather_info_text);
    forecastLayout = (LinearLayout) findViewById(R.id.forecast_layout);
    aqiText = (TextView) findViewById(R.id.aqi_text);
    pm25Text = (TextView) findViewById(R.id.pm25_text);
    comfortText = (TextView) findViewById(R.id.comfort_text);
    carWashText = (TextView) findViewById(R.id.car_wash_text);
    sportText = (TextView) findViewById(R.id.sport_text);
    swipeRefresh = (SwipeRefreshLayout) findViewById(R.id.swipe_refresh);
    swipeRefresh.setColorSchemeResources(R.color.colorPrimary);
    drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    navButton = (Button) findViewById(R.id.nav_button);
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
    String weatherString = prefs.getString("weather", null);
    if (weatherString != null) {
        // 有缓存时直接解析天气数据
        Weather weather = Utility.handleWeatherResponse(weatherString);
        mWeatherId = weather.basic.weatherId;
        showWeatherInfo(weather);
    } else {
        // 无缓存时去服务器查询天气
        mWeatherId = getIntent().getStringExtra("weather_id");
        weatherLayout.setVisibility(View.INVISIBLE);
        requestWeather(mWeatherId);
    }
    swipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            requestWeather(mWeatherId);
        }
    });
    navButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            drawerLayout.openDrawer(GravityCompat.START);
        }
    });
    String bingPic = prefs.getString("bing_pic", null);
    if (bingPic != null) {
        Glide.with(this).load(bingPic).into(bingPicImg);
    } else {
        loadBingPic();
    }
}
 
开发者ID:zjutcmos,项目名称:HappyWeather,代码行数:60,代码来源:WeatherActivity.java

示例8: onPostExecute

import android.widget.ScrollView; //导入方法依赖的package包/类
@Override
protected void onPostExecute(Void result) {
    Activity activity = mWeakReference.get();

    ScrollView mDetails_layout = (ScrollView) activity.findViewById(R.id.details_container_scrollable_view);
    TextView regionTextView = (TextView) activity.findViewById(R.id.RegionandLocations);
    TextView caseBeginningTextView = (TextView) activity.findViewById(R.id.caseBeginningTextView);
    TextView caseEndingTextView = (TextView) activity.findViewById(R.id.caseEndingTextView);
    TextView caseDescriptionTextView = (TextView) activity.findViewById(R.id.caseDescriptionTextView);
    TextView caseTextView = (TextView) activity.findViewById(R.id.caseTextView);
    TextView caseLocations = (TextView) activity.findViewById(R.id.caseLocations);
    ProgressBar progressBar = (ProgressBar) activity.findViewById(R.id.progressBar2);
    LinearLayout mDetails_container_data = (LinearLayout) activity.findViewById(R.id.details_container_data);

    // When user clicks back button, views destroyed and get null.
    // so I check if a view is null then I canceled the async task.
    // else continue working

    // fixing this issue
    // https://console.firebase.google.com/project/admob-app-id-4592869261/monitoring/app/android:com.droidprogramming.automatedearlywarningsystem/cluster/c5f947ab

    if (regionTextView == null) {
        cancel(true);
    } else {
        if (mRegionTextView == null) {
            String messageNoInternet = "يرجى التحقق من الاتصال بالانترنت, ثم اعد المحاولة بأعادة الدخول, يرجى التحقق من وجود اشارة انترنت قوية";
            Toast.makeText(activity, messageNoInternet, Toast.LENGTH_LONG).show();
            progressBar.setVisibility(View.INVISIBLE);

        } else {
            regionTextView.setText(mRegionTextView);
            caseBeginningTextView.setText(mCaseBeginningTextView);
            caseEndingTextView.setText(mCaseEndingTextView);
            caseDescriptionTextView.setText(mCaseDescriptionTextView);
            caseTextView.setText(mCaseTextView);
            caseLocations.setText(mCaseLocations);

            progressBar.setVisibility(View.INVISIBLE);
            mDetails_layout.setVisibility(View.VISIBLE);
            mDetails_container_data.setVisibility(View.VISIBLE);
        }
    }
}
 
开发者ID:mzdhr,项目名称:WarningSystemWeather-Android-App,代码行数:44,代码来源:DetailsAsync.java

示例9: onCreate

import android.widget.ScrollView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    try {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_weather);
        //初始化各控件
        bingPicImg = (ImageView) findViewById(R.id.bing_pic_img);
        weatherLayout = (ScrollView) findViewById(R.id.weather_layout);
        titleCity = (TextView) findViewById(R.id.title_city);
        titleUpdateTime = (TextView) findViewById(R.id.title_update_time);
        degreeText = (TextView) findViewById(R.id.degree_text);
        weatherInfoText = (TextView) findViewById(R.id.weather_info_text);
        forecastLayout = (LinearLayout) findViewById(R.id.forecast_layout);
        aqiText = (TextView) findViewById(R.id.aqi_text);
        pm25Text = (TextView) findViewById(R.id.pm25_text);
        comfortText = (TextView) findViewById(R.id.comfort_text);
        carWashText = (TextView) findViewById(R.id.car_wash_text);
        sportText = (TextView) findViewById(R.id.sport_text);
        SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
        String weatherString = prefs.getString("weather",null);
        if (weatherString != null){
            //有缓存时直接解析天气数据
            Weather weather = Utility.handleWeatherResponse(weatherString);
            showWeatherInfo(weather);
        } else {
            //无缓存时去服务器查询天气
            String weatherId = getIntent().getStringExtra("weather_id");
            weatherLayout.setVisibility(View.INVISIBLE);
            requestWeather(weatherId);
        }
        String bingPic = prefs.getString("bing_pic",null);
        if (bingPic != null){
            Glide.with(this).load(bingPic).into(bingPicImg);
        } else {
            loadBingPic();
        }
    }catch (Exception e){
        Toast.makeText(this, "OnCreate出错", Toast.LENGTH_SHORT).show();
        e.printStackTrace();
    }


}
 
开发者ID:newDeepLearing,项目名称:BestWeather,代码行数:44,代码来源:WeatherActivity.java

示例10: onCreate

import android.widget.ScrollView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (Build.VERSION.SDK_INT >= 21) {
        View decorView = getWindow().getDecorView();
        decorView.setSystemUiVisibility(
                View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
        getWindow().setStatusBarColor(Color.TRANSPARENT);
    }
    setContentView(R.layout.activity_weather);
    // 初始化各控件
    bingPicImg = (ImageView) findViewById(R.id.bing_pic_img);
    weatherLayout = (ScrollView) findViewById(R.id.weather_layout);
    titleCity = (TextView) findViewById(R.id.title_city);
    titleUpdateTime = (TextView) findViewById(R.id.title_update_time);
    degreeText = (TextView) findViewById(R.id.degree_text);
    weatherInfoText = (TextView) findViewById(R.id.weather_info_text);
    forecastLayout = (LinearLayout) findViewById(R.id.forecast_layout);
    aqiText = (TextView) findViewById(R.id.aqi_text);
    pm25Text = (TextView) findViewById(R.id.pm25_text);
    comfortText = (TextView) findViewById(R.id.comfort_text);
    carWashText = (TextView) findViewById(R.id.car_wash_text);
    sportText = (TextView) findViewById(R.id.sport_text);
    swipeRefresh = (SwipeRefreshLayout) findViewById(R.id.swipe_refresh);
    swipeRefresh.setColorSchemeResources(R.color.colorPrimary);
    drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    navButton = (Button) findViewById(R.id.nav_button);
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
    String weatherString = prefs.getString("weather", null);
    if (weatherString != null) {
        // 有缓存时直接解析天气数据
        Weather weather = Utility.handleWeatherResponse(weatherString);
        mWeatherId = weather.basic.weatherId;
        showWeatherInfo(weather);
    } else {
        // 无缓存时去服务器查询天气
        mWeatherId = getIntent().getStringExtra("weather_id");
        weatherLayout.setVisibility(View.INVISIBLE);
        requestWeather(mWeatherId);
    }
    swipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            requestWeather(mWeatherId);
        }
    });
    String bingPic = prefs.getString("bing_pic", null);
    if (bingPic != null) {
        Glide.with(this).load(bingPic).into(bingPicImg);
    } else {
        loadBingPic();
    }
    navButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            drawerLayout.openDrawer(GravityCompat.START);
        }
    });
}
 
开发者ID:qiaopeichen,项目名称:jojoweather,代码行数:60,代码来源:WeatherActivity.java

示例11: onCreate

import android.widget.ScrollView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);



    if (Build.VERSION.SDK_INT >= 21) {
        View decorView = getWindow().getDecorView();
        decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
        getWindow().setStatusBarColor(Color.TRANSPARENT);
    }


    setContentView(R.layout.activity_weather);

    //初始化控件
    weatherLayout = (ScrollView) findViewById(R.id.weather_layout);
    titleCity = (TextView) findViewById(R.id.title_city);
    titleUpdateTime = (TextView) findViewById(R.id.title_update_time);
    degreeText = (TextView) findViewById(R.id.degree_text);
    weatherInfoText = (TextView) findViewById(R.id.weather_info_text);
    forecastLayout = (LinearLayout) findViewById(R.id.forecast_layout);
    aqiText = (TextView) findViewById(R.id.aqi_text);
    pm25Text = (TextView) findViewById(R.id.pm25_text);
    comfortText = (TextView) findViewById(R.id.comfort_text);
    carWashText = (TextView) findViewById(R.id.car_wash_text);
    sportText = (TextView) findViewById(R.id.sport_text);
    bingPicImg = (ImageView) findViewById(R.id.bing_pic_img);
    swipeRefresh = (SwipeRefreshLayout) findViewById(R.id.swipe_refresh);
    swipeRefresh.setColorSchemeResources(R.color.colorPrimary);
    drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    navButton = (Button) findViewById(R.id.nav_button);


    final String weatherId;
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
    String weatherString = prefs.getString("weather", null);
    if (weatherString != null) {
        Weather weather = Utility.handleWeatherResponse(weatherString);
        weatherId = weather.basic.weatherId;
        showWeatherInfo(weather);
    } else {
        weatherId = getIntent().getStringExtra("weather_id");
        weatherLayout.setVisibility(View.INVISIBLE);
        requestWeather(weatherId);
    }

    String bingPic = prefs.getString("bing_pic", null);
    if (bingPic != null) {
        Glide.with(this).load(bingPic).into(bingPicImg);
    } else {
        loadBingPic();
    }

    swipeRefresh.setOnRefreshListener(() -> {
        requestWeather(weatherId);
    });

    navButton.setOnClickListener(v -> {
        drawerLayout.openDrawer(GravityCompat.START);
    });

}
 
开发者ID:chquanquan,项目名称:EasyWeather_Android,代码行数:65,代码来源:WeatherActivity.java

示例12: onCreateView

import android.widget.ScrollView; //导入方法依赖的package包/类
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view  = inflater.inflate(R.layout.activity_weather,container,false);
    swipeRefresh = (SwipeRefreshLayout) view.findViewById(R.id.swipe_layout);
    scrWeatherLayout = (ScrollView)view.findViewById(R.id.weather_scrollView);
    tempText = (TextView) view.findViewById(R.id.temp);
    imgWeather= (ImageView)view.findViewById(R.id.img_cond);
    weatherInfoText = (TextView)view.findViewById(R.id.weather_info);
    hourforecastLayout= (LinearLayout)view.findViewById(R.id.hour_layout);
    forecastLayout = (LinearLayout)view.findViewById(R.id.forecast_layout);
    aqiText = (TextView)view.findViewById(R.id.aqi_text);
    airQlty= (TextView)view.findViewById(R.id.airQlty);
    pm25Text = (TextView)view.findViewById(R.id.pm2_5);
    airBrf = (TextView)view.findViewById(R.id.sug_air);
    comfBrf= (TextView)view.findViewById(R.id.sug_comf);
    fluBrf= (TextView)view.findViewById(R.id.sug_flu);
    drsgBrf= (TextView)view.findViewById(R.id.sug_drsg);
    airTxt = (TextView)view.findViewById(R.id.air_txt);
    comfortTxt = (TextView)view.findViewById(R.id.comf_txt);
    influenzaTxt = (TextView)view.findViewById(R.id.flu_txt);
    dressTxt = (TextView)view.findViewById(R.id.drsg_txt);

    weatherId = (String) getArguments().get("weather_id");
        scrWeatherLayout.setVisibility(View.INVISIBLE);
        if (weatherId !=null) {
            requestWeather(weatherId);

        }
        //刷新控件的实现

    swipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
            @Override
            public void onRefresh() {
                if (weatherId!=null){
                    requestWeather(weatherId);
                    Toast.makeText(getActivity(), "更新成功( •̀ .̫ •́ )✧", Toast.LENGTH_SHORT).show();
                }else{
                    Log.d("LifeCycle","swipeWeatherId is null");
                }

            }
        });
    Log.d("LifeCycle","WeatherFragment_onCreateView");
    return view;
}
 
开发者ID:linchupeng,项目名称:YourWeather,代码行数:47,代码来源:WeatherFragment.java

示例13: onCreate

import android.widget.ScrollView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (Build.VERSION.SDK_INT >= 21) {
        View decorView = getWindow().getDecorView();
        decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
        getWindow().setStatusBarColor(Color.TRANSPARENT);
    }
    setContentView(R.layout.activity_waether);
    //初始化各控件
    bingpicImg = (ImageView) findViewById(R.id.bing_pic_img);
    weatherLayout = (ScrollView) findViewById(R.id.weather_layout);
    titleCity = (TextView) findViewById(R.id.title_city);
    titleUpdateTime = (TextView) findViewById(R.id.title_update_time);
    degreeText = (TextView) findViewById(R.id.degree_text);
    weatherInfoText = (TextView) findViewById(R.id.weather_info_text);
    forecasetLayout = (LinearLayout) findViewById(R.id.forecast_layout);
    aqiText = (TextView) findViewById(R.id.aqi_text);
    pm25Text = (TextView) findViewById(R.id.pm25_text);
    comfortText = (TextView) findViewById(R.id.comfort_text);
    carWashText = (TextView) findViewById(R.id.car_wash_text);
    sportText = (TextView) findViewById(R.id.sport_text);
    swipeRefresh = (SwipeRefreshLayout) findViewById(R.id.swipe_refresh);
    swipeRefresh.setColorSchemeResources(R.color.colorPrimary);
    drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    navButton = (Button) findViewById(R.id.nav_button);
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
    String weatherString = prefs.getString("weather", null);
    if (weatherString != null) {
        //有缓存时直接解析天气数据
        Weather weather = Utility.handleWeatherResponse(weatherString);
        mWeatherId = weather.basic.weatherId;
        showWeatherInfo(weather);
    } else {
        //无缓存时去服务器查询天气
        mWeatherId = getIntent().getStringExtra("weather_id");
        weatherLayout.setVisibility(View.INVISIBLE);
        requestWeather(mWeatherId);
    }

    swipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            requestWeather(mWeatherId);
        }
    });

    navButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            drawerLayout.openDrawer(GravityCompat.START);
        }
    });

    String bingPic = prefs.getString("bing_pic", null);
    String time = prefs.getString("time", null);
    SimpleDateFormat sDateFormat = new SimpleDateFormat("yyyy-MM-dd");
    String date = sDateFormat.format(new java.util.Date());
    if (date.equals(time)){
        if (bingPic != null) {
            Glide.with(this).load(bingPic).into(bingpicImg);
        } else {
            loadBingPic();
        }
    }else{
        loadBingPic();
    }
}
 
开发者ID:mzhkby,项目名称:coolweater,代码行数:69,代码来源:WaetherActivity.java

示例14: initView

import android.widget.ScrollView; //导入方法依赖的package包/类
private void initView() {
    drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    navButton = (Button) findViewById(R.id.nav_button);
    navButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            drawerLayout.openDrawer(GravityCompat.START);
        }
    });
    swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_refresh);
    swipeRefreshLayout.setColorSchemeResources(R.color.colorPrimary);
    weatherLayout = (ScrollView) findViewById(R.id.weather_layout);
    titleCity = (TextView) findViewById(R.id.title_city);
    titleUpdateTime = (TextView) findViewById(R.id.title_update_time);
    degreeText = (TextView) findViewById(R.id.degree_text);
    weatherInfoText = (TextView) findViewById(R.id.weather_info_text);
    forecastLayout = (LinearLayout) findViewById(R.id.forcast_layout);
    aqiText = (TextView) findViewById(R.id.aqi_text);
    pm25Text = (TextView) findViewById(R.id.pm25_text);
    comfortText = (TextView) findViewById(R.id.comfort_text);
    carWashText = (TextView) findViewById(R.id.car_wash_text);
    sportText = (TextView) findViewById(R.id.sport_text);
    bingPicImg = (ImageView) findViewById(R.id.bing_pic_img);
    String bingPic = ShareUtil.getString(this, "bing_pic", null);
    if (bingPic != null) {
        Picasso.with(this).load(bingPic).into(bingPicImg);
    } else {
        loadBingPic();
    }
    String weatherString = ShareUtil.getString(this, "weather", null);
    final String weatherId;
    if (weatherString != null) {
        //有缓存时直接解析天气数据
        Weather weather = ParsingJson.handleWeatherResponse(weatherString);
        showWeatherInfo(weather);
    } else {
        //无缓存时去服务器查询天气
        weatherId = ShareUtil.getString(WeatherActivity.this, StaticClass.WEATHER_ID, null);
        weatherLayout.setVisibility(View.INVISIBLE);
        requestWeather(weatherId);
    }
    swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            String refreshWeatherId = ShareUtil.getString(WeatherActivity.this, StaticClass.WEATHER_ID,
                    null);
            requestWeather(refreshWeatherId);
        }
    });
}
 
开发者ID:Hultron,项目名称:LifeHelper,代码行数:51,代码来源:WeatherActivity.java

示例15: onCreate

import android.widget.ScrollView; //导入方法依赖的package包/类
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (Build.VERSION.SDK_INT > 19) {
        View decorView = getWindow().getDecorView();
        decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
                View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
        getWindow().setStatusBarColor(Color.TRANSPARENT);
    }
    setContentView(R.layout.activity_weather);
    bingPicImg = (ImageView) findViewById(R.id.bing_pic_image);
    weatherLayout = (ScrollView) findViewById(R.id.weather_layout);
    titleCity = (TextView) findViewById(R.id.title_city);
    titleUpdateTime = (TextView) findViewById(R.id.title_update_time);
    degreeText = (TextView) findViewById(R.id.degree_text);
    weatherInfoText = (TextView) findViewById(R.id.weather_info_text);
    forecastLayout = (LinearLayout) findViewById(R.id.forecast_layout);
    aqiText = (TextView) findViewById(R.id.aqi_text);
    pm25Text = (TextView) findViewById(R.id.pm25_text);
    comfortText = (TextView) findViewById(R.id.comfort_text);
    carWashText = (TextView) findViewById(R.id.car_wash_text);
    sportText = (TextView) findViewById(R.id.sport_text);
    swipeRefresh = (SwipeRefreshLayout) findViewById(R.id.swipe_refresh);
    drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    navButton = (Button) findViewById(R.id.nav_button);
    swipeRefresh.setColorSchemeResources(R.color.colorPrimary);
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
    navButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            drawerLayout.openDrawer(GravityCompat.START);
        }
    });
    String bingPic = prefs.getString("bing_pic", null);
    if (bingPic != null) {
        Glide.with(this).load(bingPic).into(bingPicImg);
    } else {
        loadBingPic();
    }
    String weatherString = prefs.getString("weather", null);
    if (weatherString != null) {
        // 有缓存时直接解析天气数据
        Weather weather = Utility.handleWeatherResponse(weatherString);
        mWeatherId = weather.basic.weatherId;
        showWeatherInfo(weather);
        // 开启后台更新服务
        Intent intent = new Intent(this, AutoUpdateService.class);
        startService(intent);
    } else {
        // 无缓存时去服务器查询
        mWeatherId = getIntent().getStringExtra("weather_id");
        weatherLayout.setVisibility(View.INVISIBLE);
        requestWeather(mWeatherId);
    }
    swipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            requestWeather(mWeatherId);
        }
    });
}
 
开发者ID:typer9527,项目名称:project-weather,代码行数:62,代码来源:WeatherActivity.java


注:本文中的android.widget.ScrollView.setVisibility方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。