當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。