示例#1
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mainActivity = (MainActivity) this.getContext();
    View rootView = inflater.inflate(R.layout.fragment_main_gps, container, false);

    // Initialize controls
    gpsRootLayout = (LinearLayout) rootView.findViewById(R.id.gpsRootLayout);
    gpsSnrView = (GpsSnrView) rootView.findViewById(R.id.gpsSnrView);
    gpsStatusView = new GpsStatusView(rootView.getContext());
    LinearLayout.LayoutParams params =
        new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    params.gravity = Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL;
    params.weight = 1;
    gpsRootLayout.addView(gpsStatusView, 0, params);
    gpsLatLayout = (LinearLayout) rootView.findViewById(R.id.gpsLatLayout);
    gpsLat = (TextView) rootView.findViewById(R.id.gpsLat);
    gpsLonLayout = (LinearLayout) rootView.findViewById(R.id.gpsLonLayout);
    gpsLon = (TextView) rootView.findViewById(R.id.gpsLon);
    gpsCoordLayout = (LinearLayout) rootView.findViewById(R.id.gpsCoordLayout);
    gpsCoord = (TextView) rootView.findViewById(R.id.gpsCoord);
    orDeclination = (TextView) rootView.findViewById(R.id.orDeclination);
    gpsSpeed = (TextView) rootView.findViewById(R.id.gpsSpeed);
    gpsSpeedUnit = (TextView) rootView.findViewById(R.id.gpsSpeedUnit);
    gpsAlt = (TextView) rootView.findViewById(R.id.gpsAlt);
    gpsAltUnit = (TextView) rootView.findViewById(R.id.gpsAltUnit);
    gpsTime = (TextView) rootView.findViewById(R.id.gpsTime);
    gpsBearing = (TextView) rootView.findViewById(R.id.gpsBearing);
    gpsAccuracy = (TextView) rootView.findViewById(R.id.gpsAccuracy);
    gpsAccuracyUnit = (TextView) rootView.findViewById(R.id.gpsAccuracyUnit);
    gpsOrientation = (TextView) rootView.findViewById(R.id.gpsOrientation);
    gpsSats = (TextView) rootView.findViewById(R.id.gpsSats);
    gpsTtff = (TextView) rootView.findViewById(R.id.gpsTtff);

    df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.ROOT);

    mainActivity.gpsSectionFragment = this;

    return rootView;
  }
示例#2
0
 @Override
 public void onDestroyView() {
   super.onDestroyView();
   if (mainActivity.gpsSectionFragment == this) mainActivity.gpsSectionFragment = null;
 }