Example usage for android.widget FrameLayout addView

List of usage examples for android.widget FrameLayout addView

Introduction

In this page you can find the example usage for android.widget FrameLayout addView.

Prototype

public void addView(View child) 

Source Link

Document

Adds a child view.

Usage

From source file:dk.dr.radio.diverse.PagerSlidingTabStrip.java

private void addIconTabBdeTekstOgBillede(final int position, int resId, String title) {
      FrameLayout tabfl = new FrameLayout(getContext());
      ImageView tabi = new ImageView(getContext());
      tabi.setContentDescription(title);
      tabi.setImageResource(resId);/*www  .j  a v a  2  s . co m*/
      tabi.setVisibility(View.INVISIBLE);
      TextView tabt = new TextView(getContext());
      tabt.setText(title);
      tabt.setTypeface(App.skrift_gibson);
      tabt.setGravity(Gravity.CENTER);
      tabt.setSingleLine();

      tabfl.addView(tabi);
      tabfl.addView(tabt);

      LayoutParams lp = (LayoutParams) tabi.getLayoutParams();
      lp.gravity = Gravity.CENTER;
      lp = (LayoutParams) tabt.getLayoutParams();
      lp.width = lp.height = ViewGroup.LayoutParams.MATCH_PARENT;
      lp.gravity = Gravity.CENTER;

      addTab(position, tabfl);
  }

From source file:com.facebook.android.friendsmash.ScoreboardFragment.java

private void populateScoreboard() {
    // Ensure all components are firstly removed from scoreboardContainer
    scoreboardContainer.removeAllViews();

    // Ensure the progress spinner is hidden
    progressContainer.setVisibility(View.INVISIBLE);

    // Ensure scoreboardEntriesList is not null and not empty first
    if (application.getScoreboardEntriesList() == null || application.getScoreboardEntriesList().size() <= 0) {
        closeAndShowError(getResources().getString(R.string.error_no_scores));
    } else {//  w w  w . jav  a  2  s .  c o  m
        // Iterate through scoreboardEntriesList, creating new UI elements for each entry
        int index = 0;
        Iterator<ScoreboardEntry> scoreboardEntriesIterator = application.getScoreboardEntriesList().iterator();
        while (scoreboardEntriesIterator.hasNext()) {
            // Get the current scoreboard entry
            final ScoreboardEntry currentScoreboardEntry = scoreboardEntriesIterator.next();

            // FrameLayout Container for the currentScoreboardEntry ...

            // Create and add a new FrameLayout to display the details of this entry
            FrameLayout frameLayout = new FrameLayout(getActivity());
            scoreboardContainer.addView(frameLayout);

            // Set the attributes for this frameLayout
            int topPadding = getResources().getDimensionPixelSize(R.dimen.scoreboard_entry_top_margin);
            frameLayout.setPadding(0, topPadding, 0, 0);

            // ImageView background image ...
            {
                // Create and add an ImageView for the background image to this entry
                ImageView backgroundImageView = new ImageView(getActivity());
                frameLayout.addView(backgroundImageView);

                // Set the image of the backgroundImageView
                String uri = "drawable/scores_stub_even";
                if (index % 2 != 0) {
                    // Odd entry
                    uri = "drawable/scores_stub_odd";
                }
                int imageResource = getResources().getIdentifier(uri, null, getActivity().getPackageName());
                Drawable image = getResources().getDrawable(imageResource);
                backgroundImageView.setImageDrawable(image);

                // Other attributes of backgroundImageView to modify
                FrameLayout.LayoutParams backgroundImageViewLayoutParams = new FrameLayout.LayoutParams(
                        FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT);
                int backgroundImageViewMarginTop = getResources()
                        .getDimensionPixelSize(R.dimen.scoreboard_background_imageview_margin_top);
                backgroundImageViewLayoutParams.setMargins(0, backgroundImageViewMarginTop, 0, 0);
                backgroundImageViewLayoutParams.gravity = Gravity.LEFT;
                if (index % 2 != 0) {
                    // Odd entry
                    backgroundImageViewLayoutParams.gravity = Gravity.RIGHT;
                }
                backgroundImageView.setLayoutParams(backgroundImageViewLayoutParams);
            }

            // ProfilePictureView of the current user ...
            {
                // Create and add a ProfilePictureView for the current user entry's profile picture
                ProfilePictureView profilePictureView = new ProfilePictureView(getActivity());
                frameLayout.addView(profilePictureView);

                // Set the attributes of the profilePictureView
                int profilePictureViewWidth = getResources()
                        .getDimensionPixelSize(R.dimen.scoreboard_profile_picture_view_width);
                FrameLayout.LayoutParams profilePictureViewLayoutParams = new FrameLayout.LayoutParams(
                        profilePictureViewWidth, profilePictureViewWidth);
                int profilePictureViewMarginLeft = 0;
                int profilePictureViewMarginTop = getResources()
                        .getDimensionPixelSize(R.dimen.scoreboard_profile_picture_view_margin_top);
                int profilePictureViewMarginRight = 0;
                int profilePictureViewMarginBottom = 0;
                if (index % 2 == 0) {
                    profilePictureViewMarginLeft = getResources()
                            .getDimensionPixelSize(R.dimen.scoreboard_profile_picture_view_margin_left);
                } else {
                    profilePictureViewMarginRight = getResources()
                            .getDimensionPixelSize(R.dimen.scoreboard_profile_picture_view_margin_right);
                }
                profilePictureViewLayoutParams.setMargins(profilePictureViewMarginLeft,
                        profilePictureViewMarginTop, profilePictureViewMarginRight,
                        profilePictureViewMarginBottom);
                profilePictureViewLayoutParams.gravity = Gravity.LEFT;
                if (index % 2 != 0) {
                    // Odd entry
                    profilePictureViewLayoutParams.gravity = Gravity.RIGHT;
                }
                profilePictureView.setLayoutParams(profilePictureViewLayoutParams);

                // Finally set the id of the user to show their profile pic
                profilePictureView.setProfileId(currentScoreboardEntry.getId());
            }

            // LinearLayout to hold the text in this entry

            // Create and add a LinearLayout to hold the TextViews
            LinearLayout textViewsLinearLayout = new LinearLayout(getActivity());
            frameLayout.addView(textViewsLinearLayout);

            // Set the attributes for this textViewsLinearLayout
            FrameLayout.LayoutParams textViewsLinearLayoutLayoutParams = new FrameLayout.LayoutParams(
                    FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT);
            int textViewsLinearLayoutMarginLeft = 0;
            int textViewsLinearLayoutMarginTop = getResources()
                    .getDimensionPixelSize(R.dimen.scoreboard_textviews_linearlayout_margin_top);
            int textViewsLinearLayoutMarginRight = 0;
            int textViewsLinearLayoutMarginBottom = 0;
            if (index % 2 == 0) {
                textViewsLinearLayoutMarginLeft = getResources()
                        .getDimensionPixelSize(R.dimen.scoreboard_textviews_linearlayout_margin_left);
            } else {
                textViewsLinearLayoutMarginRight = getResources()
                        .getDimensionPixelSize(R.dimen.scoreboard_textviews_linearlayout_margin_right);
            }
            textViewsLinearLayoutLayoutParams.setMargins(textViewsLinearLayoutMarginLeft,
                    textViewsLinearLayoutMarginTop, textViewsLinearLayoutMarginRight,
                    textViewsLinearLayoutMarginBottom);
            textViewsLinearLayoutLayoutParams.gravity = Gravity.LEFT;
            if (index % 2 != 0) {
                // Odd entry
                textViewsLinearLayoutLayoutParams.gravity = Gravity.RIGHT;
            }
            textViewsLinearLayout.setLayoutParams(textViewsLinearLayoutLayoutParams);
            textViewsLinearLayout.setOrientation(LinearLayout.VERTICAL);

            // TextView with the position and name of the current user
            {
                // Set the text that should go in this TextView first
                int position = index + 1;
                String currentScoreboardEntryTitle = position + ". " + currentScoreboardEntry.getName();

                // Create and add a TextView for the current user position and first name
                TextView titleTextView = new TextView(getActivity());
                textViewsLinearLayout.addView(titleTextView);

                // Set the text and other attributes for this TextView
                titleTextView.setText(currentScoreboardEntryTitle);
                titleTextView.setTextAppearance(getActivity(), R.style.ScoreboardPlayerNameFont);
            }

            // TextView with the score of the current user
            {
                // Create and add a TextView for the current user score
                TextView scoreTextView = new TextView(getActivity());
                textViewsLinearLayout.addView(scoreTextView);

                // Set the text and other attributes for this TextView
                scoreTextView.setText("Score: " + currentScoreboardEntry.getScore());
                scoreTextView.setTextAppearance(getActivity(), R.style.ScoreboardPlayerScoreFont);
            }

            // Finally make this frameLayout clickable so that a game starts with the user smashing
            // the user represented by this frameLayout in the scoreContainer
            frameLayout.setOnTouchListener(new OnTouchListener() {

                @Override
                public boolean onTouch(View v, MotionEvent event) {
                    if (event.getAction() == MotionEvent.ACTION_UP) {
                        Bundle bundle = new Bundle();
                        bundle.putString("user_id", currentScoreboardEntry.getId());

                        Intent i = new Intent();
                        i.putExtras(bundle);

                        getActivity().setResult(Activity.RESULT_FIRST_USER, i);
                        getActivity().finish();
                        return false;
                    } else {
                        return true;
                    }
                }

            });

            // Increment the index before looping back
            index++;
        }
    }
}

From source file:com.putaotown.views.PagerSlidingTabStrip.java

private void addIconTab(final int position, int resId) {
    boolean isMessage = false; //??
    if (resId == R.drawable.iconfont_message || resId == R.drawable.iconfont_message_press)
        isMessage = true;// w  w  w  . ja v a2  s . co m

    ImageButton tab = new ImageButton(getContext());
    //      LinearLayout.LayoutParams param = new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.MATCH_PARENT, 1);
    LinearLayout.LayoutParams param = new LinearLayout.LayoutParams(
            (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, tabWidth,
                    getResources().getDisplayMetrics()),
            (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, tabWidth,
                    getResources().getDisplayMetrics()));
    int padding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 10,
            getResources().getDisplayMetrics());

    if (isMessage) {
        FrameLayout.LayoutParams paramx = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
                (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, tabWidth,
                        getResources().getDisplayMetrics()));
        FrameLayout flayout = new FrameLayout(this.getContext());
        param.gravity = Gravity.RIGHT;
        flayout.setLayoutParams(param);
        flayout.setPadding(padding, padding, padding, padding);
        View view = inflate(this.getContext(), R.layout.actionbar_mess_view, null);
        this.messRedPos = view.findViewById(R.id.actionbar_mess_redpos);
        this.messImage = (ImageView) view.findViewById(R.id.actionbar_mess_icon);
        flayout.addView(view);
        flayout.setTag("mess"); //??
        addTab(position, flayout);
    } else {
        tab.setLayoutParams(param);
        tab.setPadding(padding, padding, padding, padding);
        tab.setImageResource(resId);
        tab.setScaleType(ScaleType.CENTER_INSIDE);
        tab.setAdjustViewBounds(true);
        addTab(position, tab);
    }

}

From source file:gov.wa.wsdot.android.wsdot.ui.tollrates.I405TollRatesFragment.java

/**
 * Adds a toll rate accuracy disclaimer to the bottom of the view
 * @param root// w w  w .  j  a v a2s . co m
 */
private void addDisclaimerView(ViewGroup root) {
    FrameLayout frame = root.findViewById(R.id.list_container);
    TextView textView = new TextView(getContext());
    textView.setBackgroundColor(getResources().getColor(R.color.alerts));
    textView.setText(
            "Estimated toll rates provided as a courtesy. Youll always pay the toll you see on actual road signs when you enter.");
    textView.setPadding(15, 20, 15, 15);
    FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT,
            FrameLayout.LayoutParams.WRAP_CONTENT);
    params.gravity = Gravity.BOTTOM;
    textView.setLayoutParams(params);
    frame.addView(textView);
}

From source file:feipai.qiangdan.my.SuperAwesomeCardFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);

    FrameLayout fl = new FrameLayout(getActivity());
    fl.setLayoutParams(params);//from w ww  .ja  v  a  2  s  .  c om

    final int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 40,
            getResources().getDisplayMetrics());

    TextView v = new TextView(getActivity());
    params.setMargins(margin, margin, margin, margin);
    v.setLayoutParams(params);
    v.setGravity(Gravity.CENTER);
    //      v.setBackgroundResource(R.drawable.ic_launcher);
    //      v.setText("CARD " + (position + 1));
    v.setText(" ");
    v.setTextSize(20);
    v.setTextColor(getActivity().getResources().getColor(R.color.address_title_color));
    //        Drawable drawable = getActivity().getDrawable(R.drawable.icon_no_order);
    Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.icon_no_order);
    BitmapDrawable bitmapDrawable = new BitmapDrawable(bitmap);
    //TextViewdrawableleft
    v.setCompoundDrawablesWithIntrinsicBounds(null, bitmapDrawable, null, null);

    fl.addView(v);
    return fl;
}

From source file:com.github.jvanhie.discogsscrobbler.SearchFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    mList = new ExpandableListView(getActivity());
    mList.setAdapter(mAdapter);//w  w  w.jav  a2s .c  o m

    mList.setOnGroupClickListener(new GroupClickHandler());

    mList.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
        @Override
        public boolean onChildClick(ExpandableListView expandableListView, View view, final int i, int i2,
                long l) {
            if (l == 0) {
                //it's a loader (yes, hackish afterthought) get the necessary data from it
                DiscogsSearchLoader loader = (DiscogsSearchLoader) mAdapter.getChild(i, i2);
                mCallbacks.setRefreshVisible(true);
                if (loader.parenttype.equals("artist")) {
                    mDiscogs.getArtistReleases(loader.parentid, loader.page,
                            new Discogs.DiscogsDataWaiter<List<DiscogsSearchRelease>>() {
                                @Override
                                public void onResult(boolean success, List<DiscogsSearchRelease> data) {
                                    if (success) {
                                        mAdapter.addChildren(i, data);
                                    }
                                    mCallbacks.setRefreshVisible(false);
                                }
                            });
                } else if (loader.parenttype.equals("label")) {
                    mDiscogs.getLabelReleases(loader.parentid, loader.page,
                            new Discogs.DiscogsDataWaiter<List<DiscogsSearchRelease>>() {
                                @Override
                                public void onResult(boolean success, List<DiscogsSearchRelease> data) {
                                    if (success) {
                                        mAdapter.addChildren(i, data);
                                    }
                                    mCallbacks.setRefreshVisible(false);
                                }
                            });
                } else if (loader.parenttype.equals("master")) {
                    mDiscogs.getMasterReleases(loader.parentid, loader.page,
                            new Discogs.DiscogsDataWaiter<List<DiscogsSearchRelease>>() {
                                @Override
                                public void onResult(boolean success, List<DiscogsSearchRelease> data) {
                                    if (success) {
                                        mAdapter.addChildren(i, data);
                                    }
                                    mCallbacks.setRefreshVisible(false);
                                }
                            });
                }
            } else {
                //normal release selected
                onItemSelected(l);
            }

            return false;
        }
    });

    //create superframe for adding list and empty view
    FrameLayout superFrame = new FrameLayout(getActivity());
    FrameLayout.LayoutParams layoutparams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT);
    superFrame.setLayoutParams(layoutparams);
    View emptyView = inflater.inflate(R.layout.fragment_empty, container, false);
    mEmptyHeading = ((TextView) emptyView.findViewById(R.id.empty_heading));
    mEmptyHeading.setText("Start searching Discogs");
    mEmptyText = ((TextView) emptyView.findViewById(R.id.empty_text));
    mEmptyText.setText("Enter a query or scan a barcode");

    if (mDiscogs == null)
        mDiscogs = Discogs.getInstance(getActivity());

    mList.setGroupIndicator(null);

    superFrame.addView(emptyView);
    mList.setEmptyView(emptyView);
    superFrame.addView(mList);

    return superFrame;
}

From source file:com.sabaibrowser.UI.java

protected void attachTabToContentView(Tab tab) {
    if ((tab == null) || (tab.getWebView() == null)) {
        return;/*from   ww  w.j ava2 s  . co  m*/
    }
    View container = tab.getViewContainer();
    WebView mainView = tab.getWebView();
    // Attach the WebView to the container and then attach the
    // container to the content view.
    FrameLayout wrapper = (FrameLayout) container.findViewById(R.id.webview_wrapper);
    ViewGroup parent = (ViewGroup) mainView.getParent();
    if (parent != wrapper) {
        if (parent != null) {
            parent.removeView(mainView);
        }
        wrapper.addView(mainView);
    }
    parent = (ViewGroup) container.getParent();
    if (parent != mContentView) {
        if (parent != null) {
            parent.removeView(container);
        }
        mContentView.addView(container, COVER_SCREEN_PARAMS);
    }
}

From source file:com.arman.efficientqhalgoforch.SuperAwesomeCardFragment.java

@Override
public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    if (position == 2) {
        final View vv = inflater.inflate(R.layout.benchmark_lay, null);

        Button run = (Button) vv.findViewById(R.id.runAlgor);
        Button reset = (Button) vv.findViewById(R.id.cleardata);
        run.setOnClickListener(new View.OnClickListener() {
            @Override/*from   w  w w .  j a v a  2  s .c  om*/
            public void onClick(View v) {
                EditText thrd;
                EditText points;
                EditText canvasY;
                EditText canvasX;
                thrd = (EditText) vv.findViewById(R.id.numberTreadstxt);
                points = (EditText) vv.findViewById(R.id.numberpoints);
                canvasX = (EditText) vv.findViewById(R.id.canvasWidth);
                canvasY = (EditText) vv.findViewById(R.id.canvasHeight);
                int threads = Integer.valueOf(thrd.getText().toString());
                int ponts = Integer.valueOf(points.getText().toString());
                int canvY = Integer.valueOf(canvasY.getText().toString());
                int canvX = Integer.valueOf(canvasX.getText().toString());

                if (threads < 1)
                    threads = 1;
                if (ponts <= 2)
                    ponts = 3;
                if (threads > ponts)
                    threads = ponts - 1;
                if (threads > 25)
                    threads = 25;
                if (canvX + 100 < ponts)
                    canvX = canvX + 100;
                if (canvY + 100 < ponts)
                    canvY = canvY + 100;

                final Point2DCloud point2DCloud = new Point2DCloud(getActivity(), ponts /* points */,
                        Utils.WIDTH = canvY, Utils.HEIGHT = canvX, true);

                int animTime = 10;
                final int finalThreads = threads;
                final int finalPonts = ponts;
                QuickHull qh = new QuickHull(point2DCloud, threads, true, animTime, new DoneListener() {
                    @Override
                    public void jobDone(int id, float time) {
                        mResults.add(new DataHolder(finalThreads, time, finalPonts));
                        updateChart(mResults);

                    }
                });
                qh.run();
                algorithmIndex = 2;

            }
        });

        reset.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                for (DataHolder hld : mResults) {
                    mResults.remove(hld);
                }

                updateChart(mResults);

            }
        });
        doHardcore(vv, inflater);

        return vv;
    } else if (position == 3) {

        final View vv = inflater.inflate(R.layout.benchmark_lay, null);

        ((TextView) vv.findViewById(R.id.nametxt)).setText("             GrahamScan\n Multithreaded Benchmark");

        Button run = (Button) vv.findViewById(R.id.runAlgor);
        Button resetgr = (Button) vv.findViewById(R.id.cleardata);
        run.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                EditText thrd;
                EditText points;
                EditText canvasY;
                EditText canvasX;
                thrd = (EditText) vv.findViewById(R.id.numberTreadstxt);
                points = (EditText) vv.findViewById(R.id.numberpoints);
                canvasX = (EditText) vv.findViewById(R.id.canvasWidth);
                canvasY = (EditText) vv.findViewById(R.id.canvasHeight);
                int threads = Integer.valueOf(thrd.getText().toString());
                int ponts = Integer.valueOf(points.getText().toString());
                int canvY = Integer.valueOf(canvasY.getText().toString());
                int canvX = Integer.valueOf(canvasX.getText().toString());

                if (threads < 1)
                    threads = 1;
                if (ponts <= 2)
                    ponts = 3;
                if (threads > ponts)
                    threads = ponts - 1;
                if (threads > 25)
                    threads = 25;
                if (canvX + 100 < ponts)
                    canvX = canvX + 100;
                if (canvY + 100 < ponts)
                    canvY = canvY + 100;

                final Point2DCloud point2DCloud = new Point2DCloud(getActivity(), ponts /* points */,
                        Utils.WIDTH = canvY, Utils.HEIGHT = canvX, true);

                int animTime = 10;
                final int finalThreads = threads;
                final int finalPonts = ponts;
                GrahamScanParallel gh = new GrahamScanParallel(point2DCloud, threads, true, animTime,
                        new DoneListener() {
                            @Override
                            public void jobDone(int id, float time) {
                                mGResults.add(new DataHolder(finalThreads, time, finalPonts));
                                updateChart(mGResults);

                            }
                        });
                gh.run();
                algorithmIndex = 3;

            }
        });

        resetgr.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                for (DataHolder hld : mGResults) {
                    mGResults.remove(hld);
                }
                updateChart(mGResults);
            }
        });
        doHardcore(vv, inflater);

        return vv;

    } else {

        if (position == 0) {

            LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);

            FrameLayout fl = new FrameLayout(getActivity());
            fl.setLayoutParams(params);

            final int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8,
                    getResources().getDisplayMetrics());

            View v = (View) inflater.inflate(R.layout.intro, null);
            params.setMargins(margin, margin, margin, margin);
            v.setLayoutParams(params);
            v.setLayoutParams(params);
            //v.setBackgroundResource(R.drawable.background_card);

            fl.addView(v);
            //fl.addView(btn);
            return fl;
        } else if (position == 1) {
            LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);

            FrameLayout fl = new FrameLayout(getActivity());
            fl.setLayoutParams(params);

            final int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8,
                    getResources().getDisplayMetrics());

            View v = (View) inflater.inflate(R.layout.algo, null);
            params.setMargins(margin, margin, margin, margin);
            v.setLayoutParams(params);
            v.setLayoutParams(params);
            //v.setBackgroundResource(R.drawable.background_card);

            fl.addView(v);

            return fl;
        }

    }
    return null;
}

From source file:edu.mum.ml.group7.guessasketch.android.EasyPaint.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // it removes the title from the actionbar(more space for icons?)
    // this.getActionBar().setDisplayShowTitleEnabled(false);

    pixels5 = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 5, getResources().getDisplayMetrics());
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

    LinearLayout parent = new LinearLayout(this);

    parent.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    parent.setOrientation(LinearLayout.VERTICAL);

    LinearLayout scrollViewParent = new LinearLayout(this);

    scrollViewParent.setLayoutParams(/*ww  w.  ja  va 2  s . c  o m*/
            new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    scrollViewParent.setOrientation(LinearLayout.HORIZONTAL);

    HorizontalScrollView predictionsHorizontalScrollView = new HorizontalScrollView(this);
    //predictionsHorizontalScrollView.setLayoutParams(new ViewGroup.LayoutParams());

    predictions = new LinearLayout(this);
    LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
    params.gravity = Gravity.CENTER_VERTICAL;
    predictions.setLayoutParams(params);

    predictions.setOrientation(LinearLayout.HORIZONTAL);

    resetPredictionsView(predictions, true);
    predictionsHorizontalScrollView.addView(predictions);

    saveButton = new Button(this);
    saveButton.setText("Send Feedback");

    predictionsHorizontalScrollView.setLayoutParams(
            new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 10.0f));

    saveButton.setLayoutParams(
            new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT, 1.0f));

    saveButton.setVisibility(View.INVISIBLE);

    FrameLayout frameLayout = new FrameLayout(this);
    frameLayout
            .setLayoutParams(new ViewGroup.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT));
    frameLayout.addView(saveButton);

    loader = new ProgressBar(this);
    loader.setLayoutParams(new ViewGroup.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
    loader.setIndeterminate(true);
    loader.setVisibility(ProgressBar.INVISIBLE);

    frameLayout.addView(loader);

    scrollViewParent.addView(predictionsHorizontalScrollView);
    scrollViewParent.addView(frameLayout);

    contentView = new MyView(this);
    parent.addView(scrollViewParent);
    parent.addView(contentView);

    setContentView(parent);

    otherLabelOnClickListener = new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Log.e("Clicked", "Other Label label '" + (String) view.getTag() + "'");
            sendScreenshot(false, feedbackType, (String) view.getTag());
        }
    };

    mPaint = new Paint();
    mPaint.setAntiAlias(true);
    mPaint.setDither(true);
    mPaint.setColor(Color.BLACK);
    mPaint.setStyle(Paint.Style.STROKE);
    mPaint.setStrokeJoin(Paint.Join.ROUND);
    mPaint.setStrokeCap(Paint.Cap.ROUND);
    mPaint.setStrokeWidth(DEFAULT_BRUSH_SIZE);

    // Where did these magic numbers come from? What do they mean? Can I change them? ~TheOpenSourceNinja
    // Absolutely random numbers in order to see the emboss. asd! ~Valerio
    mEmboss = new EmbossMaskFilter(new float[] { 1, 1, 1 }, 0.4f, 6, 3.5f);

    mBlur = new BlurMaskFilter(5, BlurMaskFilter.Blur.NORMAL);

    if (isFirstTime()) {
        AlertDialog.Builder alert = new AlertDialog.Builder(this);

        alert.setTitle(R.string.app_name);
        alert.setMessage(R.string.app_description);
        alert.setNegativeButton(R.string.continue_button, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
                Toast.makeText(getApplicationContext(), R.string.here_is_your_canvas, Toast.LENGTH_SHORT)
                        .show();
            }
        });

        alert.show();
    } else {
        Toast.makeText(getApplicationContext(), R.string.here_is_your_canvas, Toast.LENGTH_SHORT).show();
    }

    loadFromIntents();
}

From source file:com.meiste.tempalarm.ui.CurrentTemp.java

@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.current_temp);
    ButterKnife.inject(this);

    mAdapter = new SimpleCursorAdapter(this, R.layout.record, null, FROM_COLUMNS, TO_FIELDS, 0);
    mAdapter.setViewBinder(new SimpleCursorAdapter.ViewBinder() {
        @Override//from ww  w  . j  a va 2  s  .  com
        public boolean setViewValue(final View view, final Cursor cursor, final int columnIndex) {
            final TextView textView = (TextView) view;
            switch (columnIndex) {
            case COLUMN_TIMESTAMP:
                // Convert timestamp to human-readable date
                textView.setText(DateUtils.formatDateTime(getApplicationContext(), cursor.getLong(columnIndex),
                        AppConstants.DATE_FORMAT_FLAGS));
                return true;
            case COLUMN_DEGF:
                // Restrict to one decimal place
                textView.setText(String.format("%.1f", cursor.getFloat(columnIndex)));
                return true;
            case COLUMN_LIGHT:
                if (cursor.getInt(columnIndex) < mLightThreshold) {
                    textView.setText(getText(R.string.lights_on));
                } else {
                    textView.setText(getText(R.string.lights_off));
                }
                return true;
            }
            return false;
        }
    });

    final View header = getLayoutInflater().inflate(R.layout.record_header, mListView, false);
    final FrameLayout frameLayout = ButterKnife.findById(header, R.id.graph_placeholder);
    mGraph = new LineGraphView(this, "");
    mGraph.setDrawBackground(true);
    mGraph.setBackgroundColor(getResources().getColor(R.color.primary_graph));
    mGraph.setCustomLabelFormatter(new CustomLabelFormatter() {
        @Override
        public String formatLabel(final double value, final boolean isValueX) {
            if (isValueX) {
                return DateUtils.formatDateTime(getApplicationContext(), (long) value,
                        AppConstants.DATE_FORMAT_FLAGS_GRAPH);
            }
            return String.format(Locale.getDefault(), "%.1f", value);
        }
    });
    mGraph.getGraphViewStyle().setNumHorizontalLabels(AppConstants.GRAPH_NUM_HORIZONTAL_LABELS);
    frameLayout.addView(mGraph);

    mListView.addHeaderView(header, null, false);
    mListView.setAdapter(mAdapter);
    getLoaderManager().initLoader(0, null, this);
}