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.gh.bmd.jrt.android.v4.core.TestFragment.java

@Nullable
@Override//  ww w  .  java 2  s.c o  m
public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
        final Bundle savedInstanceState) {

    return new View(getActivity());
}

From source file:android.arch.lifecycle.testapp.UsualFragment.java

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    return new View(getContext());
}

From source file:com.marc.marclibs.utils.StatusBarCompat.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static View compat(Activity activity, int statusColor) {
    int color = ContextCompat.getColor(activity, R.color.primary_light);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        if (statusColor != INVALID_VAL) {
            color = statusColor;/*w w  w .j  a va 2s .  co m*/
        }
        activity.getWindow().setStatusBarColor(color);
        return null;
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT
            && Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        ViewGroup contentView = (ViewGroup) activity.findViewById(android.R.id.content);
        if (statusColor != INVALID_VAL) {
            color = statusColor;
        }
        View statusBarView = contentView.getChildAt(0);
        if (statusBarView != null && statusBarView.getMeasuredHeight() == getStatusBarHeight(activity)) {
            statusBarView.setBackgroundColor(color);
            return statusBarView;
        }
        statusBarView = new View(activity);
        ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                getStatusBarHeight(activity));
        statusBarView.setBackgroundColor(color);
        contentView.addView(statusBarView, lp);
        return statusBarView;
    }
    return null;

}

From source file:com.bs.hjsyxt.utils.StatusBarCompat.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static View compat(Activity activity, int statusColor) {
    int color = ContextCompat.getColor(activity, R.color.colorPrimaryDark);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        if (statusColor != INVALID_VAL) {
            color = statusColor;/*from   ww w  . ja  v  a2s . c  o  m*/
        }
        activity.getWindow().setStatusBarColor(color);
        return null;
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT
            && Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        ViewGroup contentView = (ViewGroup) activity.findViewById(android.R.id.content);
        if (statusColor != INVALID_VAL) {
            color = statusColor;
        }
        View statusBarView = contentView.getChildAt(0);
        if (statusBarView != null && statusBarView.getMeasuredHeight() == getStatusBarHeight(activity)) {
            statusBarView.setBackgroundColor(color);
            return statusBarView;
        }
        statusBarView = new View(activity);
        ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                getStatusBarHeight(activity));
        statusBarView.setBackgroundColor(color);
        contentView.addView(statusBarView, lp);
        return statusBarView;
    }
    return null;

}

From source file:com.yoyiyi.bookreadercopy.utils.StatusBarCompat.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP) //21
public static View compat(Activity activity, int statusColor) {
    int color = ContextCompat.getColor(activity, R.color.colorPrimaryDark);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        if (statusColor != INVALID_VAL) {
            color = statusColor;/*from w  w  w .j  a  v a 2s .  co  m*/
        }
        activity.getWindow().setStatusBarColor(color);
        return null;
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT
            && Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        ViewGroup contentView = (ViewGroup) activity.findViewById(android.R.id.content);
        if (statusColor != INVALID_VAL) {
            color = statusColor;
        }
        View statusBarView = contentView.getChildAt(0);
        if (statusBarView != null && statusBarView.getMeasuredHeight() == getStatusBarHeight(activity)) {
            statusBarView.setBackgroundColor(color);
            return statusBarView;
        }
        statusBarView = new View(activity);
        ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                getStatusBarHeight(activity));
        statusBarView.setBackgroundColor(color);
        contentView.addView(statusBarView, lp);
        return statusBarView;
    }
    return null;

}

From source file:com.google.android.api.youtube.YouTubePlayerSupportFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = new View(getActivity());
    v.setBackgroundColor(0);/*w  w  w.j  av a  2 s  .com*/
    return v;
}

From source file:com.laer.easycast.FirstPane.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View root = new View(getActivity());
    root.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
    root = inflater.inflate(R.layout.firstlayout, container, false);
    root.setBackgroundColor(Color.GRAY);
    setHasOptionsMenu(true);/*  ww w.  ja v  a  2  s .  c o  m*/
    myViewGroup = container;

    return root;
}

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

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

From source file:com.oguzbabaoglu.cardpager.example.ColorAdapter.java

@Override
public Object instantiateItem(ViewGroup container, int position) {

    View view = new View(context);
    view.setBackgroundColor(generateRandomColor());
    container.addView(view);/* w  w w .ja v a2 s  . co m*/

    return view;
}

From source file:roommateapp.info.droid.BuildingPageFragment.java

/**
 * //from w ww.  j  a va 2s.co m
 */
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View v = new View(getActivity());

    // Saves the content and position when rotation the screen
    setRetainInstance(true);

    if (activeFragment == FREEROOMS) {
        v = inflater.inflate(R.layout.view_all_rooms, container, false);
    } else if (activeFragment == ALLROOMS) {
        v = inflater.inflate(R.layout.view_free_rooms, container, false);
    }

    return v;
}