Example usage for android.view View View

List of usage examples for android.view View View

Introduction

In this page you can find the example usage for android.view View View.

Prototype

public View(Context context) 

Source Link

Document

Simple constructor to use when creating a view from code.

Usage

From source file:com.matthewmitchell.wakeifyplus.MinutesSecondsFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {

    TableRow.LayoutParams twoLP = new TableRow.LayoutParams(0, 0, 0.2f);
    TableRow.LayoutParams threeLP = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT,
            TableRow.LayoutParams.WRAP_CONTENT, 0.3f);

    View spacer = new View(activity);
    spacer.setLayoutParams(twoLP);// www.j a  v a  2s  .c o m
    spacer.setVisibility(View.INVISIBLE);

    final NumberPicker minutes = new NumberPicker(activity);
    minutes.setMaxValue(30);
    minutes.setMinValue(0);
    minutes.setValue(defaultMinute);
    minutes.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS);

    LinearLayout minutesLayout = new LinearLayout(activity);
    minutesLayout.addView(minutes);
    minutesLayout.setGravity(Gravity.CENTER);
    minutesLayout.setLayoutParams(threeLP);

    final NumberPicker seconds = new NumberPicker(activity);
    seconds.setMaxValue(59);
    seconds.setMinValue(0);
    seconds.setValue(defaultSecond);
    seconds.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS);

    LinearLayout secondsLayout = new LinearLayout(activity);
    secondsLayout.addView(seconds);
    secondsLayout.setGravity(Gravity.CENTER);
    secondsLayout.setLayoutParams(threeLP);

    LinearLayout layout = new LinearLayout(activity);
    layout.addView(spacer);
    layout.addView(minutesLayout);
    layout.addView(secondsLayout);
    layout.setWeightSum(1.0f);

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setMessage("Set Volume Ramping Time").setView(layout)
            .setPositiveButton("Set", new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    activity.rampingMinutes = minutes.getValue();
                    activity.rampingSeconds = seconds.getValue();
                    TextView edit = (TextView) activity.findViewById(R.id.volume_ramping);
                    edit.setText(activity.rampingMinutes + "m" + activity.rampingSeconds + "s");
                }

            }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    // Do nothing.
                }
            });
    // Create the AlertDialog object and return it
    return builder.create();

}

From source file:com.github.pockethub.android.ui.TabPagerFragment.java

@Override
public View createTabContent(String tag) {
    View view = new View(getActivity().getApplication());
    view.setVisibility(View.GONE);
    return view;/* w  ww. jav  a  2s.  c  o  m*/
}

From source file:com.actionbarsherlock.sample.styledactionbar.RoundedColourFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.mView = new View(this.getActivity());

    GradientDrawable background = (GradientDrawable) this.getResources().getDrawable(R.drawable.rounded_rect);
    background.setColor(this.mColor);

    this.mView.setBackgroundDrawable(background);
    LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(0, LayoutParams.FILL_PARENT, mWeight);
    lp.setMargins(this.mMarginLeft, this.mMarginTop, this.mMarginRight, this.mMarginBottom);
    this.mView.setLayoutParams(lp);
}

From source file:com.xxoo.slidingmenu.demo.fragments.ResponsiveUIActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setTitle(R.string.app_name);//from  ww w . java  2s.c  om

    setContentView(R.layout.responsive_content_frame);

    // ?? check if the content frame contains the menu frame
    if (findViewById(R.id.menu_frame) == null) {
        setBehindContentView(R.layout.menu_frame);
        getSlidingMenu().setSlidingEnabled(true);
        getSlidingMenu().setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
        // show home as up so we can toggle
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    } else {
        // ? add a dummy view
        View v = new View(this);
        setBehindContentView(v);
        getSlidingMenu().setSlidingEnabled(false);
        getSlidingMenu().setTouchModeAbove(SlidingMenu.TOUCHMODE_NONE);
    }
    //      // set the Above View Fragment
    if (savedInstanceState != null)
        mContent = getSupportFragmentManager().getFragment(savedInstanceState, "mContent");
    if (mContent == null)
        mContent = new BirdGridFragment(0);
    getSupportFragmentManager().beginTransaction().replace(R.id.content_frame, mContent).commit();

    // set the Behind View Fragment
    getSupportFragmentManager().beginTransaction().replace(R.id.menu_frame, new BirdMenuFragment()).commit();

    // customize the SlidingMenu
    SlidingMenu sm = getSlidingMenu();
    //?????
    sm.setBehindOffsetRes(R.dimen.slidingmenu_offset);
    sm.setShadowWidthRes(R.dimen.shadow_width);
    sm.setShadowDrawable(R.drawable.shadow);
    sm.setBehindScrollScale(0.25f);
    sm.setFadeDegree(0.25f);

    // show the explanation dialog
    //      if (savedInstanceState == null)
    //         new AlertDialog.Builder(this)
    //         .setTitle(R.string.what_is_this)
    //         .setMessage(R.string.responsive_explanation)
    //         .show();
}

From source file:com.tune.news.fragment.SwipeRefreshListFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mRefreshLayout = new SwipeRefreshLayout(inflater.getContext()) {
        @Override/*w  ww. jav  a2  s .c o  m*/
        public boolean canChildScrollUp() {
            return mListView != null && mListView.getFirstVisiblePosition() != 0;
        }
    };
    inflateView(inflater, mRefreshLayout, savedInstanceState);

    mListView = (ListView) mRefreshLayout.findViewById(android.R.id.list);
    if (mListView != null) {
        // HACK to be able to know when we are on the top of the list (for the swipe refresh)
        mListView.addHeaderView(new View(mListView.getContext()));
    }

    return mRefreshLayout;
}

From source file:com.wayhua.framework.base.BaseFragmentTabPager.java

@Override
public View createTabContent(String tag) {
    return ViewUtils.setGone(new View(getActivity().getApplication()), true);
}

From source file:org.puder.trs80.SettingsActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Dummy view. Will be replaced by SettingsFragment.
    setContentView(new View(this));
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getFragmentManager().beginTransaction().replace(android.R.id.content, new SettingsFragment()).commit();
}

From source file:com.example.bufferandroidproject.abs.TabPagerActivity.java

@Override
public View createTabContent(String tag) {
    return ViewUtils.setGone(new View(getApplication()), true);
}

From source file:com.technoxist.fragment.SwipeRefreshListFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mRefreshLayout = new SwipeRefreshLayout(inflater.getContext()) {
        @Override//from w w w  .  j  a  v a2 s.  c o m
        public boolean canChildScrollUp() {
            if (mListView != null) {
                return mListView.getFirstVisiblePosition() != 0;
            }
            return false;
        }
    };
    inflateView(inflater, mRefreshLayout, savedInstanceState);

    mListView = (ListView) mRefreshLayout.findViewById(android.R.id.list);
    if (mListView != null) {
        // HACK to be able to know when we are on the top of the list (for the swipe refresh)
        mListView.addHeaderView(new View(mListView.getContext()));
    }

    return mRefreshLayout;
}

From source file:me.trashout.utils.ViewUtils.java

/**
 * Create and return divider view/* ww  w . jav a  2  s .c o  m*/
 *
 * @return
 */
public static View getDividerView(Context context) {
    View divider = new View(context);
    LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 2);
    int sideMargin = ViewUtils.getPixelsFromDp(context, 20);
    int topBottomMargin = ViewUtils.getPixelsFromDp(context, 10);
    lp.setMargins(sideMargin, topBottomMargin, sideMargin, topBottomMargin);
    divider.setLayoutParams(lp);
    divider.setBackgroundColor(ContextCompat.getColor(context, R.color.separator_light));
    return divider;
}