@Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    final Button runButton = new Button(this);
    runButton.setText("Run away!");

    final RelativeLayout runLayout = (RelativeLayout) findViewById(R.id.runLayout);
    runLayout.addView(runButton);

    final RelativeLayout.LayoutParams buttonParams =
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);

    runButton.setOnClickListener(
        new Button.OnClickListener() {

          @Override
          public void onClick(View arg0) {
            // TODO Auto-generated method stub
            Random rand = new Random();
            buttonParams.leftMargin = rand.nextInt(runLayout.getWidth() - 100);
            buttonParams.topMargin = rand.nextInt(runLayout.getHeight() - 100);

            runButton.setLayoutParams(buttonParams);
          }
        });
  }
Example #2
0
  public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow()
        .setFlags(
            WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    adView = new AdView(this);
    adView.setAdUnitId("ca-app-pub-9480879598480702/4025467071");
    adView.setAdSize(AdSize.SMART_BANNER);

    RelativeLayout rl = new RelativeLayout(this);
    RelativeLayout.LayoutParams lay =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);

    lay.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    com.google.android.gms.ads.AdRequest adRequest =
        new com.google.android.gms.ads.AdRequest.Builder()
            .addTestDevice("13F77AAABEE7FB57CF4FA6BD90138B61")
            .build();
    panel = new MainGamePanel(this, adView);
    rl.addView(panel);
    rl.addView(adView, lay);

    // Carregar o adView com a solicitação de anúncio.
    adView.loadAd(adRequest);
    setContentView(rl);

    // setContentView(panel);
  }
  private RelativeLayout createPin() {
    final RelativeLayout pinLayout = new RelativeLayout(getContext());
    pinLayout.setVisibility(View.INVISIBLE);

    final Pin pin = new Pin(getContext());
    pin.setId(ID_PIN);
    final RelativeLayout.LayoutParams pinParams =
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    pinParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    pinParams.addRule(RelativeLayout.ALIGN_BOTTOM, ID_PIN_TEXT);
    pinParams.addRule(RelativeLayout.ALIGN_TOP, ID_PIN_TEXT);
    pin.setLayoutParams(pinParams);
    pinLayout.addView(pin);

    final TextView indicatorTextView = new TextView(getContext());
    indicatorTextView.setId(ID_PIN_TEXT);
    final RelativeLayout.LayoutParams indicatorParams =
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    indicatorParams.addRule(RelativeLayout.LEFT_OF, ID_PIN);
    indicatorTextView.setLayoutParams(indicatorParams);
    indicatorTextView.setTextColor(Color.WHITE);
    indicatorTextView.setGravity(Gravity.CENTER);
    indicatorTextView.setBackgroundColor(GREY_LIGHT);
    pinLayout.addView(indicatorTextView);

    return pinLayout;
  }
Example #4
0
  private void initToolbar() {
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    ImageView imageView = new ImageView(this);
    imageView.setBackgroundResource(R.drawable.ic_logo);
    RelativeLayout rl1 = (RelativeLayout) findViewById(R.id.action_logo);
    rl1.addView(imageView);

    Progress progressView = new Progress(this, true);
    RelativeLayout rl2 = (RelativeLayout) findViewById(R.id.action_progress);
    progressView.setProgress(_deposit.get_progress());
    rl2.addView(progressView);

    float values[] = {_deposit.get_principle(), _deposit.get_actInterest()};
    PieChart graphView = new PieChart(this, true);
    graphView.setValues(values);
    RelativeLayout rl3 = (RelativeLayout) findViewById(R.id.action_graph);
    rl3.addView(graphView);

    final GestureDetector detector = new GestureDetector(new SwipeGestureDetector());
    _flipper = (ViewFlipper) this.findViewById(R.id.action_flipper);
    _flipper.startFlipping();
    _flipper.setOnTouchListener(
        new View.OnTouchListener() {
          @Override
          public boolean onTouch(final View view, final MotionEvent event) {
            detector.onTouchEvent(event);
            return true;
          }
        });
  }
 private void initCrossLines() {
   getImageCordinates();
   final RelativeLayout parent = (RelativeLayout) findViewById(R.id.parent);
   result1 = new DrawView(this, coordinatesMap.get(1), coordinatesMap.get(3));
   result1.setVisibility(View.INVISIBLE);
   result2 = new DrawView(this, coordinatesMap.get(4), coordinatesMap.get(6));
   result2.setVisibility(View.INVISIBLE);
   result3 = new DrawView(this, coordinatesMap.get(7), coordinatesMap.get(9));
   result3.setVisibility(View.INVISIBLE);
   result4 = new DrawView(this, coordinatesMap.get(1), coordinatesMap.get(7));
   result4.setVisibility(View.INVISIBLE);
   result5 = new DrawView(this, coordinatesMap.get(2), coordinatesMap.get(8));
   result5.setVisibility(View.INVISIBLE);
   result6 = new DrawView(this, coordinatesMap.get(3), coordinatesMap.get(9));
   result6.setVisibility(View.INVISIBLE);
   result7 = new DrawView(this, coordinatesMap.get(3), coordinatesMap.get(7));
   result7.setVisibility(View.INVISIBLE);
   result8 = new DrawView(this, coordinatesMap.get(1), coordinatesMap.get(9));
   result8.setVisibility(View.INVISIBLE);
   parent.addView(result1);
   parent.addView(result2);
   parent.addView(result3);
   parent.addView(result4);
   parent.addView(result5);
   parent.addView(result6);
   parent.addView(result7);
   parent.addView(result8);
 }
Example #6
0
  private void initViews(Context context, int customLeftMenuId, int customRightMenuId) {
    LayoutInflater inflater =
        (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    inflater.inflate(R.layout.residemenu_custom, this);

    if (customLeftMenuId >= 0) {
      scrollViewLeftMenu = inflater.inflate(customLeftMenuId, this, false);
    } else {
      scrollViewLeftMenu =
          inflater.inflate(R.layout.residemenu_custom_left_scrollview, this, false);
      layoutLeftMenu = (LinearLayout) scrollViewLeftMenu.findViewById(R.id.layout_left_menu);
    }

    if (customRightMenuId >= 0) {
      scrollViewRightMenu = inflater.inflate(customRightMenuId, this, false);
    } else {
      scrollViewRightMenu =
          inflater.inflate(R.layout.residemenu_custom_right_scrollview, this, false);
      layoutRightMenu = (LinearLayout) scrollViewRightMenu.findViewById(R.id.layout_right_menu);
    }

    imageViewShadow = (ImageView) findViewById(R.id.iv_shadow);
    imageViewBackground = (ImageView) findViewById(R.id.iv_background);

    RelativeLayout menuHolder = (RelativeLayout) findViewById(R.id.sv_menu_holder);
    menuHolder.addView(scrollViewLeftMenu);
    menuHolder.addView(scrollViewRightMenu);
  }
  protected View createView(
      final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) {

    relativeLayout = new RelativeLayout(getActivity());
    final FrameLayout.LayoutParams relativeLayoutLayoutParams =
        new FrameLayout.LayoutParams(
            FrameLayout.LayoutParams.FILL_PARENT, FrameLayout.LayoutParams.FILL_PARENT);

    // Create loading
    RelativeLayout mRelativeLayoutLoad = new RelativeLayout(getActivity());

    this.mRenderSurfaceView = new RenderSurfaceView(getActivity());
    this.mRenderSurfaceView.setEGLConfigChooser(false);
    this.mRenderSurfaceView.setRenderer(this.mEngine, this);

    final RelativeLayout.LayoutParams surfaceViewLayoutParams =
        new RelativeLayout.LayoutParams(createSurfaceViewLayoutParams());
    surfaceViewLayoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);

    relativeLayout.addView(this.mRenderSurfaceView, surfaceViewLayoutParams);
    relativeLayout.addView(mRelativeLayoutLoad, relativeLayoutLayoutParams);

    mImageViewLoading = new ImageView(getActivity());
    mRelativeLayoutLoad.addView(mImageViewLoading, surfaceViewLayoutParams);

    return relativeLayout;
  }
Example #8
0
  private RelativeLayout getPageView() {
    rlPage = new RelativeLayout(getContext());
    rlPage.setBackgroundDrawable(background);
    if (dialogMode) {
      RelativeLayout rlDialog = new RelativeLayout(getContext());
      rlDialog.setBackgroundColor(0xc0323232);
      int dp_8 = dipToPx(getContext(), 8);
      int width = getScreenWidth(getContext()) - dp_8 * 2;
      RelativeLayout.LayoutParams lpDialog =
          new RelativeLayout.LayoutParams(width, LayoutParams.WRAP_CONTENT);
      lpDialog.topMargin = dp_8;
      lpDialog.bottomMargin = dp_8;
      lpDialog.addRule(RelativeLayout.CENTER_IN_PARENT);
      rlDialog.setLayoutParams(lpDialog);
      rlPage.addView(rlDialog);

      rlDialog.addView(getPageTitle());
      rlDialog.addView(getPageBody());
      rlDialog.addView(getImagePin());
    } else {
      rlPage.addView(getPageTitle());
      rlPage.addView(getPageBody());
      rlPage.addView(getImagePin());
    }
    return rlPage;
  }
Example #9
0
  private void p1Graph() {

    p1Series = new LineGraphSeries();
    p1Series.setColor(Color.RED);

    // p1graph.setManualYAxisBounds(127, -127);
    p1graph.addSeries(p1Series); // data
    p1graph.getViewport().setYAxisBoundsManual(true);
    p1graph.getViewport().setMaxY(4096);
    p1graph.getViewport().setMinY(-1);
    p1graph.getViewport().setScalable(false);
    p1graph.getViewport().setScrollable(false);

    p1graph.setTitle("Upper Sensor Leg");
    p1graph.setTitleColor(R.color.PMDBlue);
    p1graph.getGridLabelRenderer().setHorizontalLabelsVisible(false);
    p1graph.getGridLabelRenderer().setVerticalLabelsVisible(false);

    RelativeLayout layout = (RelativeLayout) findViewById(R.id.p1Layout);
    layout.addView(p1graph);
    //////////////////////////////////////
    p2Series = new LineGraphSeries();
    p2Series.setColor(Color.BLUE);

    // p1graph.setManualYAxisBounds(127, -127);
    p2graph.addSeries(p2Series); // data
    p2graph.getViewport().setYAxisBoundsManual(true);
    p2graph.getViewport().setMaxY(4096);
    p2graph.getViewport().setMinY(-1);
    p2graph.getViewport().setScalable(false);
    p2graph.getViewport().setScrollable(false);

    p2graph.setTitle("Lower Sensor Leg");
    p2graph.setTitleColor(R.color.PMDBlue);
    p2graph.getGridLabelRenderer().setHorizontalLabelsVisible(false);
    p2graph.getGridLabelRenderer().setVerticalLabelsVisible(false);

    RelativeLayout layout2 = (RelativeLayout) findViewById(R.id.p2Layout);
    layout2.addView(p2graph);

    //////////////////////////////////////
    vSeries = new LineGraphSeries();
    vSeries.setColor(Color.rgb(0, 156, 2));

    // p1graph.setManualYAxisBounds(127, -127);
    vgraph.addSeries(vSeries); // data
    vgraph.getViewport().setYAxisBoundsManual(true);
    vgraph.getViewport().setMaxY(4096);
    vgraph.getViewport().setMinY(-1);
    vgraph.getViewport().setScalable(false);
    vgraph.getViewport().setScrollable(false);

    vgraph.setTitle("Reference Voltage");
    vgraph.setTitleColor(R.color.PMDBlue);
    vgraph.getGridLabelRenderer().setHorizontalLabelsVisible(false);
    vgraph.getGridLabelRenderer().setVerticalLabelsVisible(false);

    RelativeLayout layout3 = (RelativeLayout) findViewById(R.id.vRefLayout);
    layout3.addView(vgraph);
  }
Example #10
0
  // shared image container
  private RelativeLayout getThumbView() {
    rlThumb = new RelativeLayout(getContext());
    rlThumb.setId(1);
    int dp_82 = dipToPx(getContext(), 82);
    int dp_98 = dipToPx(getContext(), 98);
    LayoutParams lpThumb = new LayoutParams(dp_82, dp_98);
    rlThumb.setLayoutParams(lpThumb);

    ivImage = new ImageView(getContext());
    int resId = getBitmapRes(activity, "btn_back_nor");
    if (resId > 0) {
      ivImage.setBackgroundResource(resId);
    }
    ivImage.setScaleType(ScaleType.CENTER_INSIDE);
    ivImage.setImageBitmap(image);

    int dp_4 = dipToPx(getContext(), 4);
    ivImage.setPadding(dp_4, dp_4, dp_4, dp_4);
    int dp_74 = dipToPx(getContext(), 74);
    RelativeLayout.LayoutParams lpImage = new RelativeLayout.LayoutParams(dp_74, dp_74);
    int dp_16 = dipToPx(getContext(), 16);
    int dp_8 = dipToPx(getContext(), 8);
    lpImage.setMargins(0, dp_16, dp_8, 0);
    ivImage.setLayoutParams(lpImage);
    ivImage.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            if (image != null && !image.isRecycled()) {
              PicViewer pv = new PicViewer();
              pv.setImageBitmap(image);
              pv.show(activity, null);
            }
          }
        });
    rlThumb.addView(ivImage);

    Button btn = new Button(getContext());
    btn.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            // remove the photo to share
            rlThumb.setVisibility(View.GONE);
            ivPin.setVisibility(View.GONE);
            removeImage(imgInfo);
          }
        });
    resId = getBitmapRes(activity, "img_cancel");
    if (resId > 0) {
      btn.setBackgroundResource(resId);
    }
    int dp_20 = dipToPx(getContext(), 20);
    RelativeLayout.LayoutParams lpBtn = new RelativeLayout.LayoutParams(dp_20, dp_20);
    lpBtn.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    lpBtn.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    btn.setLayoutParams(lpBtn);
    rlThumb.addView(btn);

    rlThumb.setVisibility(View.GONE);
    return rlThumb;
  }
  @Override
  public void start() {
    super.start();

    AbstractGameView gameView = GameManager.createGame(gameName, act);

    RelativeLayout mainContentHolder;
    LinearLayout dismissAlarmLayout;

    mainContentHolder = (RelativeLayout) act.findViewById(R.id.mainContentLayout);
    dismissAlarmLayout = (LinearLayout) act.findViewById(R.id.dismissAlarmLayout);

    // Make the holder for dismiss/snooze alarm buttons invisible while the game is running.
    dismissAlarmLayout.setVisibility(View.GONE);
    mainContentHolder.addView(gameView);

    // Adding all views that build the games UI after the surfaceView has been added.
    // Otherwise the UI views would all get stuck under the surface view.
    List<View> uiList = gameView.getUIComponents();
    if (uiList != null) {
      for (View v : uiList) {
        mainContentHolder.addView(v);
      }
    }
    gameView.resume();
  }
  private void addSearchLayout(RelativeLayout layout, TiViewProxy searchView, TiUIView search) {
    RelativeLayout.LayoutParams p = createBasicSearchLayout();
    p.addRule(RelativeLayout.ALIGN_PARENT_TOP);

    TiDimension rawHeight;
    if (searchView.hasProperty(TiC.PROPERTY_HEIGHT)) {
      rawHeight = TiConvert.toTiDimension(searchView.getProperty(TiC.PROPERTY_HEIGHT), 0);
    } else {
      rawHeight = TiConvert.toTiDimension(MIN_SEARCH_HEIGHT, 0);
    }
    p.height = rawHeight.getAsPixels(layout);

    View nativeView = search.getNativeView();
    layout.addView(nativeView, p);

    p = createBasicSearchLayout();
    p.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    p.addRule(RelativeLayout.BELOW, nativeView.getId());
    ViewParent parentWrapper = wrapper.getParent();
    if (parentWrapper != null && parentWrapper instanceof ViewGroup) {
      // get the previous layout params so we can reset with new layout
      ViewGroup.LayoutParams lp = wrapper.getLayoutParams();
      ViewGroup parentView = (ViewGroup) parentWrapper;
      // remove view from parent
      parentView.removeView(wrapper);
      // add new layout
      layout.addView(wrapper, p);
      parentView.addView(layout, lp);

    } else {
      layout.addView(wrapper, p);
    }
    this.searchLayout = layout;
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    XWalkPreferences.setValue(XWalkPreferences.ANIMATABLE_XWALK_VIEW, true);

    setContentView(R.layout.multi_texture_views);
    RelativeLayout parent = (RelativeLayout) findViewById(R.id.multi_texture_views);
    textDes = (TextView) findViewById(R.id.multiViews_des);
    textDes.setText(
        "This sample demonstrates Multiple TextureViews can be shown"
            + " in order. A,B,C views are TextureViews, D,E,F views are WebViews, "
            + "the sort order of A,B,C are the same with D,E,F when rotate or "
            + "restore the screen. Click \"Resize\" button to enlarge or reduce the views.");
    mResizeButton = (Button) findViewById(R.id.run_resize);
    LinearLayout btnLay = (LinearLayout) findViewById(R.id.toolbar2);
    btnLay.setY(180);
    btnLay.setX(550);
    root = (RelativeLayout) findViewById(R.id.root_views);
    for (int i = 0; i < 3; i++) {
      XWalkView xWalkView = new XWalkView(this, this);
      xWalkView.setX(i * 100);
      xWalkView.setY(130 + (i + 1) * 60);
      xWalkView.load(
          null,
          String.format(
              "<html><head><meta name='viewport' content='width=device-width'/></head>"
                  + "<body style='background-color: %s;'><h1>%s</h1></body></html>",
              i % 2 == 0 ? "white" : "grey", i == 0 ? "A" : i == 1 ? "B" : "C"));
      root.addView(xWalkView, 200, 200);
    }

    for (int i = 3; i < 6; i++) {
      WebView webView = new WebView(this);
      webView.setX(i * 100);
      webView.setY(130 + (i + 1) * 60);
      webView.loadData(
          String.format(
              "<html><body style='background-color: %s'><h1>%s</h1></body></html>",
              i % 2 == 0 ? "white" : "grey", i == 3 ? "D" : i == 4 ? "E" : "F"),
          "text/html",
          "utf-8");
      root.addView(webView, 200, 200);
    }

    setContentView(parent);
    mResizeButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            if (sizeFlag) {
              resize(root, 200, 200);
              sizeFlag = false;
            } else {
              resize(root, 400, 400);
              sizeFlag = true;
            }
          }
        });
  }
  public HsvColorPickerDialog(
      Context context, int initialColor, final OnColorSelectedListener listener) {
    super(context);
    this.listener = listener;
    this.selectedColor = initialColor;
    this.density = context.getResources().getDisplayMetrics().density;
    RelativeLayout layout = new RelativeLayout(context);

    colorWheel = new HSVColorWheel(context, initialColor);
    colorWheel.setId(ViewDefine.ViewID_Color_Wheel);
    RelativeLayout.LayoutParams lp =
        new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    lp.bottomMargin = getViewDP(ViewDefine.Type_View_BottomMargin);
    layout.addView(colorWheel, lp);

    valueSlider = new HSVValueSlider(context);
    valueSlider.setId(ViewDefine.ViewID_Value_Slider);
    lp =
        new RelativeLayout.LayoutParams(
            LayoutParams.MATCH_PARENT, getViewDP(ViewDefine.Type_ValueSlider_Height));
    lp.bottomMargin = getViewDP(ViewDefine.Type_View_BottomMargin);
    lp.addRule(RelativeLayout.BELOW, ViewDefine.ViewID_Color_Wheel);
    layout.addView(valueSlider, lp);

    selectedColorView = new View(context);
    selectedColorView.setBackgroundColor(selectedColor);
    lp =
        new RelativeLayout.LayoutParams(
            LayoutParams.MATCH_PARENT, getViewDP(ViewDefine.Type_ValueSlider_Height));
    lp.addRule(RelativeLayout.BELOW, ViewDefine.ViewID_Value_Slider);
    FrameLayout selectedColorborder = new FrameLayout(context);
    selectedColorborder.addView(selectedColorView);
    layout.addView(selectedColorborder, lp);
    selectedColorView.setBackgroundColor(ViewDefine.BORDER_COLOR);

    colorWheel.setListener(
        new OnColorSelectedListener() {
          @Override
          public void colorSelected(Integer color) {
            valueSlider.setColor(color, true);
          }
        });
    valueSlider.setListener(
        new OnColorSelectedListener() {
          @Override
          public void colorSelected(Integer color) {
            selectedColor = color;
            selectedColorView.setBackgroundColor(color);
          }
        });

    setButton(BUTTON_NEGATIVE, context.getString(android.R.string.cancel), clickListener);
    setButton(BUTTON_POSITIVE, context.getString(android.R.string.ok), clickListener);

    int tmp = getViewDP(ViewDefine.Type_Whole_Padding);
    setView(layout, tmp, tmp / 2, tmp, tmp / 2);
    setTitle("Pick a Color(HSV)");
  }
  /** Create the view in which the video will be rendered. */
  private void setupView() {
    LinearLayout lLinLayout = new LinearLayout(this);
    lLinLayout.setId(1);
    lLinLayout.setOrientation(LinearLayout.VERTICAL);
    lLinLayout.setGravity(Gravity.CENTER);
    lLinLayout.setBackgroundColor(Color.BLACK);

    LayoutParams lLinLayoutParms =
        new LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT);
    lLinLayout.setLayoutParams(lLinLayoutParms);

    this.setContentView(lLinLayout);

    RelativeLayout lRelLayout = new RelativeLayout(this);
    lRelLayout.setId(2);
    lRelLayout.setGravity(Gravity.CENTER);
    lRelLayout.setBackgroundColor(Color.BLACK);
    android.widget.RelativeLayout.LayoutParams lRelLayoutParms =
        new android.widget.RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT);
    lRelLayout.setLayoutParams(lRelLayoutParms);
    lLinLayout.addView(lRelLayout);

    mVideoView = new VideoView(this);
    mVideoView.setId(3);
    android.widget.RelativeLayout.LayoutParams lVidViewLayoutParams =
        new android.widget.RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    lVidViewLayoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);
    mVideoView.setLayoutParams(lVidViewLayoutParams);
    lRelLayout.addView(mVideoView);

    mProgressBar = new ProgressBar(this);
    mProgressBar.setIndeterminate(true);
    mProgressBar.setVisibility(View.VISIBLE);
    mProgressBar.setEnabled(true);
    mProgressBar.setId(4);
    android.widget.RelativeLayout.LayoutParams lProgressBarLayoutParms =
        new android.widget.RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    lProgressBarLayoutParms.addRule(RelativeLayout.CENTER_IN_PARENT);
    mProgressBar.setLayoutParams(lProgressBarLayoutParms);
    lRelLayout.addView(mProgressBar);

    mProgressMessage = new TextView(this);
    mProgressMessage.setId(5);
    android.widget.RelativeLayout.LayoutParams lProgressMsgLayoutParms =
        new android.widget.RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    lProgressMsgLayoutParms.addRule(RelativeLayout.CENTER_HORIZONTAL);
    lProgressMsgLayoutParms.addRule(RelativeLayout.BELOW, 4);
    mProgressMessage.setLayoutParams(lProgressMsgLayoutParms);
    mProgressMessage.setTextColor(Color.LTGRAY);
    mProgressMessage.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12);
    mProgressMessage.setText("...");
    lRelLayout.addView(mProgressMessage);
  }
Example #16
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    boardView = new PlayingFieldView(this);
    caughtCounterView = new TextView(this);
    caughtCounterView.append(babatextBase + "0");
    caughtCounterView.setTextSize(24);

    // Create a Layout in which to add the Views

    layout = new RelativeLayout(this);

    layout.addView(caughtCounterView);
    layout.addView(boardView);

    setContentView(layout);

    // enforce the Portrait orientation
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    // to prevent the sleep mode on this activity
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    sensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
    sensorAccelerometer = sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);

    //        Game.getInstance().addAI();
    //
    //        // temporary code till BT connection is ready - test observer
    //        // TODO - replace with "game.update(null, player)" - player with new coordinates
    //        TimerTask task = new TimerTask() {
    //            @Override
    //            public void run() {
    //                Game.getInstance().moveAI();
    //            }
    //        };
    //        Timer timer = new Timer();
    //        timer.schedule(task, new Date(), 300);
    // temporary code end

    //        //setContentView(R.layout.activity_playing_field);
    //
    ////        final View controlsView = findViewById(R.id.fullscreen_content_controls);
    ////        final View contentView = findViewById(R.id.fullscreen_content);
    ////
    ////        // Upon interacting with UI controls, delay any scheduled hide()
    ////        // operations to prevent the jarring behavior of controls going away
    ////        // while interacting with the UI.
    ////        findViewById(R.id.dummy_button).setOnTouchListener(mDelayHideTouchListener);

    //        DisplayMetrics displayMetrics = new DisplayMetrics();
    //        WindowManager wm = (WindowManager)
    // getApplicationContext().getSystemService(Context.WINDOW_SERVICE);
    //        wm.getDefaultDisplay().getMetrics(displayMetrics);
    //        int x = displayMetrics.widthPixels;
    //        int y = displayMetrics.heightPixels;
  }
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.detailcontainer);
   prodDetailHeader = (RelativeLayout) findViewById(R.id.detailHeader);
   prodDetailBody = (RelativeLayout) findViewById(R.id.detailBody);
   prodDetailHeader.addView(getDetailHeaderView());
   View vi = getDetailBodyView();
   prodDetailBody.addView(vi);
 }
  @Override
  public void processProperties(KrollDict d) {
    tableView = new TiTableView(proxy.getTiContext(), (TableViewProxy) proxy);
    tableView.setOnItemClickListener(this);

    if (d.containsKey(TiC.PROPERTY_SEARCH)) {
      RelativeLayout layout = new RelativeLayout(proxy.getTiContext().getActivity());
      layout.setGravity(Gravity.NO_GRAVITY);
      layout.setPadding(0, 0, 0, 0);

      TiViewProxy searchView = (TiViewProxy) d.get(TiC.PROPERTY_SEARCH);
      TiUISearchBar searchBar =
          (TiUISearchBar) searchView.getView(proxy.getTiContext().getActivity());
      searchBar.setOnSearchChangeListener(tableView);
      searchBar.getNativeView().setId(102);

      RelativeLayout.LayoutParams p =
          new RelativeLayout.LayoutParams(
              RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT);
      p.addRule(RelativeLayout.ALIGN_PARENT_TOP);
      p.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
      p.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
      p.height = 52;

      layout.addView(searchBar.getNativeView(), p);

      p =
          new RelativeLayout.LayoutParams(
              RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT);
      p.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
      p.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
      p.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
      p.addRule(RelativeLayout.BELOW, 102);
      layout.addView(tableView, p);
      setNativeView(layout);
    } else {
      setNativeView(tableView);
    }

    if (d.containsKey(TiC.PROPERTY_FILTER_ATTRIBUTE)) {
      tableView.setFilterAttribute(TiConvert.toString(d, TiC.PROPERTY_FILTER_ATTRIBUTE));
    } else {
      // Default to title to match iPhone default.
      proxy.setProperty(TiC.PROPERTY_FILTER_ATTRIBUTE, TiC.PROPERTY_TITLE, false);
      tableView.setFilterAttribute(TiC.PROPERTY_TITLE);
    }

    boolean filterCaseInsensitive = true;
    if (d.containsKey(TiC.PROPERTY_FILTER_CASE_INSENSITIVE)) {
      filterCaseInsensitive = TiConvert.toBoolean(d, TiC.PROPERTY_FILTER_CASE_INSENSITIVE);
    }
    tableView.setFilterCaseInsensitive(filterCaseInsensitive);
    super.processProperties(d);
  }
  @Before
  public void setUp() throws Exception {
    Activity context = Robolectric.buildActivity(Activity.class).create().get();
    relativeLayout = new RelativeLayout(context);
    relativeLayout.setId((int) Utils.generateUniqueId());
    viewGroup = new LinearLayout(context);

    BaseForwardingNativeAd baseForwardingNativeAd = new BaseForwardingNativeAd() {};
    baseForwardingNativeAd.setTitle("test title");
    baseForwardingNativeAd.setText("test text");
    baseForwardingNativeAd.setCallToAction("test call to action");
    baseForwardingNativeAd.setClickDestinationUrl("destinationUrl");

    nativeResponse =
        new NativeResponse(
            context,
            "impressionTrackerUrl",
            "clickTrackerUrl",
            "test ID",
            baseForwardingNativeAd,
            mock(MoPubNative.MoPubNativeListener.class));

    titleView = new TextView(context);
    titleView.setId((int) Utils.generateUniqueId());
    textView = new TextView(context);
    textView.setId((int) Utils.generateUniqueId());
    callToActionView = new Button(context);
    callToActionView.setId((int) Utils.generateUniqueId());
    mainImageView = new ImageView(context);
    mainImageView.setId((int) Utils.generateUniqueId());
    iconImageView = new ImageView(context);
    iconImageView.setId((int) Utils.generateUniqueId());
    badView = new ImageView(context);
    badView.setId((int) Utils.generateUniqueId());

    relativeLayout.addView(titleView);
    relativeLayout.addView(textView);
    relativeLayout.addView(callToActionView);
    relativeLayout.addView(mainImageView);
    relativeLayout.addView(iconImageView);
    relativeLayout.addView(badView);

    viewBinder =
        new ViewBinder.Builder(relativeLayout.getId())
            .titleId(titleView.getId())
            .textId(textView.getId())
            .callToActionId(callToActionView.getId())
            .mainImageId(mainImageView.getId())
            .iconImageId(iconImageView.getId())
            .build();

    subject = new MoPubNativeAdRenderer(viewBinder);
  }
Example #20
0
  /**
   * 描述:创建.
   *
   * @param savedInstanceState the saved instance state
   * @see android.support.v4.app.FragmentActivity#onCreate(android.os.Bundle)
   */
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    mInflater = LayoutInflater.from(this);

    // 主标题栏
    mAbTitleBar = new AbTitleBar(this);

    // 最外层布局
    ab_base = new RelativeLayout(this);
    ab_base.setBackgroundColor(Color.rgb(255, 255, 255));

    // 内容布局
    contentLayout = new RelativeLayout(this);
    contentLayout.setPadding(0, 0, 0, 0);

    // 副标题栏
    mAbBottomBar = new AbBottomBar(this);

    // 填入View
    ab_base.addView(
        mAbTitleBar,
        new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));

    mAbTitleBar.setVisibility(View.GONE);

    RelativeLayout.LayoutParams layoutParamsBottomBar =
        new RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    layoutParamsBottomBar.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
    ab_base.addView(mAbBottomBar, layoutParamsBottomBar);

    RelativeLayout.LayoutParams layoutParamsContent =
        new RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    layoutParamsContent.addRule(RelativeLayout.BELOW, mAbTitleBar.getId());
    layoutParamsContent.addRule(RelativeLayout.ABOVE, mAbBottomBar.getId());
    ab_base.addView(contentLayout, layoutParamsContent);

    // Application初始化
    abApplication = getApplication();

    // 设置ContentView
    setContentView(
        ab_base,
        new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));

    AbActivityManager.getInstance().addActivity(this);
  }
Example #21
0
  public boolean addViews(
      String type,
      RelativeLayout layout,
      Map<String, Float> list,
      String previous,
      String relativeLeft,
      String relativeRight) {
    // add or modify
    RelativeLayout.LayoutParams leftLayoutParams =
        new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);

    RelativeLayout.LayoutParams rightLayoutParams =
        new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);

    for (Map.Entry<String, Float> listElement : list.entrySet()) {
      // key and value become textviews
      String rightChild = type + listElement.getValue() + "_id";
      int resourceID = this.findResource(rightChild, null, null);
      if (resourceID != 0) {
        TextView value = (TextView) findViewById(resourceID);
        value.setText(listElement.getValue().toString());
        continue;
      }

      TextView value = new TextView(this);
      value.setText(listElement.getValue().toString());
      value.setId(resourceID);

      String leftChild = type + listElement.getKey() + "_id";
      resourceID = this.findResource(leftChild, null, null);
      TextView key = new TextView(this);
      key.setText(listElement.getKey());
      key.setId(resourceID);

      leftLayoutParams.addRule(RelativeLayout.BELOW, this.findResource(previous, null, null));
      leftLayoutParams.addRule(
          RelativeLayout.ALIGN_LEFT, this.findResource(relativeLeft, null, null));

      rightLayoutParams.addRule(RelativeLayout.ALIGN_TOP, this.findResource(leftChild, null, null));
      rightLayoutParams.addRule(
          RelativeLayout.ALIGN_LEFT, this.findResource(relativeRight, null, null));

      layout.addView(key, leftLayoutParams);
      layout.addView(value, rightLayoutParams);

      previous = leftChild;
    }
    return true;
  }
Example #22
0
  private void createLayout(int value, int max, String text) {
    maxValue = max;

    RelativeLayout textValueLayout = new RelativeLayout(getContext());
    textValueLayout.setLayoutParams(
        new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
    textValueLayout.setPadding(0, Misc.densify(4), 0, Misc.densify(4));

    TextView sliderTextVal = new TextView(getContext());
    sliderTextVal.setText(text);
    sliderTextVal.setTextSize(TypedValue.COMPLEX_UNIT_SP, Misc.densify(6));
    sliderTextVal.setPadding(Misc.densify(16), Misc.densify(4), Misc.densify(4), Misc.densify(4));
    sliderTextVal.setTextColor(Color.parseColor("#2c2e2f"));
    RelativeLayout.LayoutParams localTextViewParams =
        new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    localTextViewParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
    sliderTextVal.setLayoutParams(localTextViewParams);

    sliderTitleVal = new TextView(getContext());
    sliderTitleVal.setTextSize(TypedValue.COMPLEX_UNIT_SP, Misc.densify(6));

    sliderTitleVal.setText(String.valueOf(value));
    sliderTitleVal.setTextColor(Color.parseColor("#2c2e2f"));
    sliderTitleVal.setPadding(0, Misc.densify(4), Misc.densify(16), Misc.densify(4));
    RelativeLayout.LayoutParams hueTitleValParams =
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    hueTitleValParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, RelativeLayout.TRUE);
    sliderTitleVal.setLayoutParams(hueTitleValParams);

    LinearLayout hueSliderLayout = new LinearLayout(getContext());
    hueSliderLayout.setLayoutParams(
        new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));

    seekSlider = new HtcSeekBar(getContext());
    seekSlider.setMax(max);
    seekSlider.setOnSeekBarChangeListener(this);
    seekSlider.setProgress(value + (maxValue / 2));
    seekSlider.setLayoutParams(
        new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));

    textValueLayout.addView(sliderTextVal);
    textValueLayout.addView(sliderTitleVal);
    hueSliderLayout.addView(seekSlider);

    addView(textValueLayout);
    addView(hueSliderLayout);

    return;
  }
Example #23
0
  @Test
  public void removeFromParent_withMultipleChildren_shouldRemoveCorrectChild() throws Exception {
    parent.addView(new TextView(context));

    assertThat(parent.getChildCount()).isEqualTo(1);

    parent.addView(subject);

    assertThat(parent.getChildCount()).isEqualTo(2);

    Views.removeFromParent(subject);
    assertThat(parent.getChildCount()).isEqualTo(1);

    assertThat(parent.getChildAt(0)).isInstanceOf(TextView.class);
  }
  @Override
  public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    that = this;

    requestWindowFeature(Window.FEATURE_NO_TITLE);
    this.getWindow()
        .setFlags(
            WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

    container = new RelativeLayout(this);
    RelativeLayout.LayoutParams topLayoutParams =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
    container.setLayoutParams(topLayoutParams);
    setContentView(container);

    mWebView = new WebView(this);
    RelativeLayout.LayoutParams webviewLayoutParams =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
    mWebView.setLayoutParams(webviewLayoutParams);

    container.addView(mWebView);
  }
 public void drawAnnotations() {
   mAnnotationLabelOverlay.removeAllViews();
   if (mQueryResult == null) {
     return;
   }
   int[] actImageRect = getBitmapPositionInsideImageView(mImageView);
   List<Annotation> annotations = mQueryResult.annotations;
   int index = -1;
   for (Annotation anno : annotations) {
     index++;
     LabelView label = new LabelView(getActivity());
     label.mLabelText.setVisibility(View.VISIBLE);
     label.mLabelText.setText(anno.text);
     label.mPosition = index;
     float padding = 100;
     float cx = anno.getCenterX() * actImageRect[2];
     float cy = anno.getCenterY() * actImageRect[3];
     if (cx > actImageRect[2] - padding) {
       cx = actImageRect[2] - padding + randomInt(-30, 30);
     } else if (cx < padding) {
       cx = padding + randomInt(-30, 30);
     }
     if (cy > actImageRect[3] - padding) {
       cy = actImageRect[3] - padding + randomInt(-30, 30);
     } else if (cy < padding) {
       cy = padding + randomInt(-30, 30);
     }
     RelativeLayout.LayoutParams params =
         new RelativeLayout.LayoutParams(
             ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
     params.leftMargin = (int) cx + actImageRect[0];
     params.topMargin = (int) cy + actImageRect[1];
     mAnnotationLabelOverlay.addView(label, params);
     label.setOnClickListener(
         new View.OnClickListener() {
           @Override
           public void onClick(View v) {
             LabelView view = (LabelView) v;
             Log.d("label position: ", "" + view.mPosition);
             int position = view.mPosition;
             if (position >= 0 && position < mAnnotationList.size()) {
               mLinearLayoutManager.scrollToPosition(position);
             }
             //                    String text = view.mLabelText.getText().toString();
             //                    AnnotationDetailFragment fragment = new
             // AnnotationDetailFragment();
             //                    Bundle args = new Bundle();
             //                    args.putString("annotation_text", text);
             //                    fragment.setArguments(args);
             //
             // getFragmentManager().beginTransaction().replace(R.id.frame_container,
             // fragment).addToBackStack(null).commit();
           }
         });
     if (mLabels == null) {
       mLabels = new ArrayList<>();
     }
     mLabels.add(label);
   }
 }
Example #26
0
  public void add_car(int x, int y, int rotation, int state) {

    ImageView car = new ImageView(getActivity());

    carList.add(car);
    switch (state) {
      case 0:
        car.setBackground(getResources().getDrawable(R.drawable.ic_launcher0));
        break;
      case 1:
        car.setBackground(getResources().getDrawable(R.drawable.ic_launcher1));
        break;
      case 2:
        car.setBackground(getResources().getDrawable(R.drawable.ic_launcher2));
        break;
      default:
        break;
    }

    RelativeLayout.LayoutParams layoutParams =
        new LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    layoutParams.setMargins(x, y, 10, 10); // 150-1650/50-950
    car.setRotation(rotation);
    layout.addView(car, layoutParams);
  }
Example #27
0
  private MonthView addMonth(int index, CalendarDays days, int height, boolean first) {
    layout = new RelativeLayout(getContext());
    layout.setLayoutParams(
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT));
    layout.setClickable(true);
    layout.setOnClickListener(clickListener);
    mv[index] = new MonthView(getContext());

    RelativeLayout.LayoutParams lp =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    lp.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE);
    mv[index].setMonthIndex(index);
    mv[index].setLayoutParams(lp);
    mv[index].setDays(days, height);
    mv[index].setFocusable(false);
    mv[index].setOnDayClickListener(this);
    layout.addView(mv[index]);
    if (first) {
      addView(layout, 0);
    } else {
      addView(layout);
    }
    return mv[index];
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {

    // Turn off the window's title bar
    requestWindowFeature(Window.FEATURE_NO_TITLE);

    // Super
    super.onCreate(savedInstanceState);

    // Fullscreen mode
    getWindow()
        .setFlags(
            WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

    // We create our Surfaceview for our OpenGL here.
    glSurfaceView = new GLSurf(this);

    // Set our view.
    setContentView(R.layout.activity_main);

    // Retrieve our Relative layout from our main layout we just set to our view.
    RelativeLayout layout = (RelativeLayout) findViewById(R.id.gamelayout);

    // Attach our surfaceview to our relative layout from our main layout.
    RelativeLayout.LayoutParams glParams =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
    layout.addView(glSurfaceView, glParams);
  }
  public void displayAjustView(RecyclingBitmapDrawable value) {
    if (value != null && value.getBitmap() != null) {
      this.value = value;
      adjustView =
          new AdjustView(
              context, value.getBitmap().getWidth(), value.getBitmap().getHeight(), value);
      adjustView.setBackgroundColor(Color.TRANSPARENT);
      //			adjustView.setImageBitmap(bitmap);

      relayout.removeAllViews();
      RelativeLayout.LayoutParams params =
          new RelativeLayout.LayoutParams(
              android.widget.RelativeLayout.LayoutParams.WRAP_CONTENT,
              android.widget.RelativeLayout.LayoutParams.WRAP_CONTENT);

      Tools.initWidth = value.getBitmap().getWidth();
      Tools.initHeight = value.getBitmap().getHeight();

      params.topMargin = (int) (screenHeight * 0.5 - value.getBitmap().getHeight() * 0.5);
      params.leftMargin = (int) (screenWidth * 0.5 - value.getBitmap().getWidth() * 0.5);
      relayout.addView(adjustView, params);

      float rate = (float) viewWidth / viewHeight;
      int mheight = (int) (value.getBitmap().getHeight() * 0.5);
      int mwidth = (int) (mheight * rate);

      adjustView.auto_setAdjustImg(0, 0, mwidth, mheight);
    } else relayout.removeAllViews();
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_display_message);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                .setAction("Action", null)
                .show();
          }
        });
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    Intent intent = getIntent();
    String message = intent.getStringExtra(MyActivity.EXTRA_MESSAGE);
    TextView textView = new TextView(this);
    textView.setTextSize(40);
    textView.setText(message);

    RelativeLayout layout = (RelativeLayout) findViewById(R.id.content);
    layout.addView(textView);
  }