(澳门银河官网下载) 如何在Fragment中添加SurfaceView,像墨迹天气的动态背景
澳门银河官网
澳门银河官网
当前位置 : 澳门银河官网 > 澳门银河官网下载

(澳门银河官网下载) 如何在Fragment中添加SurfaceView,像墨迹天气的动态背景

我想在我的程序中植入墨迹天气那种动态背景,
使用activity的setContentView运行动态背景没问题:
public class SnowActivity extends Activity {
SnowSurfaceView snowSurfaceView;

@Override
public void onCreateBundle savedInstanceState {
    // TODO Auto-generated method stub
    super.onCreatesavedInstanceState;
    Log.i"icer", "-->onCreate";
    snowSurfaceView = new SnowSurfaceViewthis;
    setContentViewsnowSurfaceView;
}

问题是如何在Fragment中让这种动态背景效果运行起来,保持原布局不变,通过获取到的天气状态判断来显示具体出什么动态背景效果,让该效果像在activity一样,在该Fragment的布局上单独运行。
public class ZeroFragment extends Fragment implements OnClickListener {

SnowSurfaceView snowSurfaceView;

@Override
public View onCreateViewLayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState {
    View view = inflater.inflateR.layout.fragment_zero, container, false;

    wearTextView = TextView view.findViewByIdR.id.zero_wear;
    weatherTextView = TextView view.findViewByIdR.id.zero_weather;

    getckWeather getckweather = new getckWeather;
    getckweather.execute;//去获取天气数据,天气数据存到myGlobal这个application里
    loadAnimation;// 根据获取到的天气判断打开相应背景动画
    return view;
}

private void loadAnimation {

    if myGlobal.weather.equals"晴" {
        Toast.makeTextgetActivity, "开始动画", Toast.LENGTH_SHORT.show;
        snowSurfaceView = new SnowSurfaceViewgetActivity;//在这之后该加什么代码??
    }
}

广告位

澳门银河官网