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.firesoft.member.Activity.C0_ServiceListActivity.java

@Override
public void OnMessageResponse(String url, JSONObject jo, AjaxStatus status) throws JSONException {

    mListView.stopRefresh();/*  w  ww  . j a  v a  2 s . com*/
    mListView.stopLoadMore();
    if (url.endsWith(ApiInterface.MEMBER_LIST)) {
        if (null != jo) {
            memberlistResponse response = new memberlistResponse();
            response.fromJson(jo);

            if (null == mListWithServiceAdapter) {
                mListWithServiceAdapter = new C0_ServiceListAdapter(this, mDataModel.dataList);
                mListView.setAdapter(mListWithServiceAdapter);
                footView = new View(this);
                footView.setEnabled(true);
                footView.setLayoutParams(new AbsListView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                        ImageUtil.Dp2Px(this, 60)));
                mListView.addFooterView(footView);
            } else {
                mListWithServiceAdapter.notifyDataSetChanged();
            }
            mListView.stopLoadMore();
            if (0 == response.more) {
                mListView.setPullLoadEnable(false);
            }

            Rect frame = new Rect();
            getWindow().getDecorView().getWindowVisibleDisplayFrame(frame);
            int statusBarHeight = frame.top;

            int listHeight = mListView.getHeight();
            int screenHeight = getResources().getDisplayMetrics().heightPixels - ImageUtil.Dp2Px(this, 50)
                    - statusBarHeight;

            if (listHeight >= screenHeight) {
                footView.setVisibility(View.VISIBLE);
            } else {
                footView.setVisibility(View.GONE);
                mListView.removeFooterView(footView);
            }
        }

    }

}

From source file:com.me.harris.listviewitemanimations._01_activityAnim.ActivityAnimations.java

private void handleStatusBar() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT
            && Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        ViewGroup mContentView = (ViewGroup) findViewById(Window.ID_ANDROID_CONTENT);

        /* int statusBarHeight = getStatusBarHeight();
                //  w w  w .  ja  va2 s.c o  m
         View mChildView = mContentView.getChildAt(0);
         if (mChildView != null) {
        FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) mChildView.getLayoutParams();
        //? ChildView  marginTop, ?
        if (lp != null && lp.topMargin < statusBarHeight && lp.height != statusBarHeight) {
            //?
            ViewCompat.setFitsSystemWindows(mChildView, false);
            lp.topMargin += statusBarHeight;
            mChildView.setLayoutParams(lp);
        }
         }
                
         View statusBarView = mContentView.getChildAt(0);
         if (statusBarView != null && statusBarView.getLayoutParams() != null && statusBarView.getLayoutParams().height == statusBarHeight) {
        //???? View
        statusBarView.setBackgroundColor(ContextCompat.getColor(this,R.color.colorPrimaryDark));
        return;
         }*/
        int statusBarHeight = getStatusBarHeight();
        View statusBarView = new View(this);
        ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                statusBarHeight);
        statusBarView.setBackgroundColor(ContextCompat.getColor(this, R.color.colorPrimaryDark));
        //? ContentView ? View
        mContentView.addView(statusBarView, 0, lp);
    }

}

From source file:com.aosijia.dragonbutler.ui.widget.ActionSheet.java

private View createView() {
    FrameLayout parent = new FrameLayout(getActivity());
    parent.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
            FrameLayout.LayoutParams.MATCH_PARENT));
    mBg = new View(getActivity());
    mBg.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
            FrameLayout.LayoutParams.MATCH_PARENT));
    mBg.setBackgroundColor(Color.argb(136, 0, 0, 0));
    mBg.setId(ActionSheet.BG_VIEW_ID);//from  ww w. jav  a  2 s  .  c  o  m
    mBg.setOnClickListener(this);

    mPanel = new LinearLayout(getActivity());
    FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
            FrameLayout.LayoutParams.WRAP_CONTENT);
    params.gravity = Gravity.BOTTOM;
    mPanel.setLayoutParams(params);
    mPanel.setOrientation(LinearLayout.VERTICAL);
    if (checkDeviceHasNavigationBar(getActivity())) {
        parent.setPadding(0, 0, 0, getNavBarHeight(getActivity()));
    } else {
        parent.setPadding(0, 0, 0, 0);
    }

    parent.addView(mBg);
    parent.addView(mPanel);
    return parent;
}

From source file:com.shenzhen.elson.selectordialoglib.SelectorDialog.java

private View createView() {
    FrameLayout parent = new FrameLayout(getActivity());
    parent.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
            FrameLayout.LayoutParams.MATCH_PARENT));
    mBg = new View(getActivity());
    mBg.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
            FrameLayout.LayoutParams.MATCH_PARENT));
    mBg.setBackgroundColor(Color.argb(136, 0, 0, 0));
    mBg.setId(SelectorDialog.BG_VIEW_ID);
    mBg.setOnClickListener(this);

    mPanel = new LinearLayout(getActivity());
    FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
            FrameLayout.LayoutParams.WRAP_CONTENT);
    params.gravity = Gravity.BOTTOM;//w  w w.  j av a2  s  .c  om
    mPanel.setLayoutParams(params);
    mPanel.setOrientation(LinearLayout.VERTICAL);
    parent.setPadding(0, 0, 0, getNavBarHeight(getActivity()));
    parent.addView(mBg);
    parent.addView(mPanel);
    return parent;
}

From source file:ng.kingsley.android.widget.CollectionView.java

private View getRowView(int row, View convertView, ViewGroup parent) {
    if (computeRowContent(row, mRowComputeResult)) {
        return makeRow(convertView, mRowComputeResult, parent);
    } else {/*from ww w  . j a v a  2 s.  c  o m*/
        Log.e(TAG, "Invalid row passed to getView: " + row);
        return convertView != null ? convertView : new View(getContext());
    }
}

From source file:com.pdftron.pdf.utils.ViewerUtils.java

/**
 * Helper method that creates a flashing view.
 *
 * @param context the context/*from   w ww  .  j  a  v a 2  s. c o  m*/
 *
 * @return a new View with the background color already set.
 */
public static View createFlashingView(Context context) {
    View flashingView = new View(context);
    flashingView.setBackgroundColor(context.getResources().getColor(R.color.annotation_flashing_box));
    return flashingView;
}

From source file:com.echlabsw.android.drawertab.MainActivity.java

@Override
public View createTabContent(String tag) {
    // Stub empty View
    return new View(this);
}

From source file:com.suning.mobile.ebuy.lottery.utils.view.ScrollingTabsView.java

/**
 * Creates and returns a new Separator View
 * /*from www .ja  va 2s  .c  om*/
 * @return
 */
private View getSeparator() {
    View v = new View(mContext);

    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(mDividerWidth, LayoutParams.MATCH_PARENT);
    params.setMargins(0, mDividerMarginTop, 0, mDividerMarginBottom);
    v.setLayoutParams(params);

    if (mDividerDrawable != null) {
        v.setBackgroundDrawable(mDividerDrawable);
    } else {
        v.setBackgroundColor(mDividerColor);
    }
    return v;
}

From source file:at.alladin.rmbt.android.fragments.history.RMBTFilterFragment.java

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

    super.onCreateView(inflater, container, savedInstanceState);

    view = inflater.inflate(R.layout.history_filter, container, false);

    deviceListView = (LinearLayout) view.findViewById(R.id.deviceList);
    networkListView = (LinearLayout) view.findViewById(R.id.networkList);

    final RelativeLayout resultLimitView = (RelativeLayout) view.findViewById(R.id.Limit25Wrapper);
    limit25CheckBox = (CheckBox) view.findViewById(R.id.Limit25CheckBox);

    if (activity.getHistoryResultLimit() == 250)
        limit25CheckBox.setChecked(true);
    else/*from  www  . j a  va  2 s.  c  o m*/
        limit25CheckBox.setChecked(false);

    resultLimitView.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(final View v) {
            if (limit25CheckBox.isChecked()) {
                limit25CheckBox.setChecked(false);
                activity.setHistoryResultLimit(0);
            } else {
                limit25CheckBox.setChecked(true);
                activity.setHistoryResultLimit(250);
            }

        }

    });

    devicesToShow = activity.getHistoryFilterDevicesFilter();
    networksToShow = activity.getHistoryFilterNetworksFilter();

    if (devicesToShow == null && networksToShow == null) {
        devicesToShow = new ArrayList<String>();
        networksToShow = new ArrayList<String>();
    }

    final float scale = activity.getResources().getDisplayMetrics().density;

    final int leftRightItem = Helperfunctions.dpToPx(5, scale);
    // int topBottomItem = Helperfunctions.dpToPx(5, scale);

    // int leftRightDiv = Helperfunctions.dpToPx(0, scale);
    // int topBottomDiv = Helperfunctions.dpToPx(0, scale);
    final int heightDiv = Helperfunctions.dpToPx(1, scale);

    // int topBottomImg = Helperfunctions.dpToPx(1, scale);

    final String historyDevices[] = activity.getHistoryFilterDevices();

    if (historyDevices != null) {

        for (int i = 0; i < historyDevices.length; i++) {

            final RelativeLayout singleItemLayout = new RelativeLayout(activity); // (LinearLayout)measurememtItemView.findViewById(R.id.measurement_item);

            singleItemLayout.setId(i);
            singleItemLayout.setClickable(true);
            singleItemLayout.setBackgroundResource(R.drawable.list_selector);

            singleItemLayout.setLayoutParams(
                    new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));

            final TextView itemTitle = new TextView(activity, null, R.style.textMediumLight);

            RelativeLayout.LayoutParams layout = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                    LayoutParams.MATCH_PARENT);
            layout.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
            layout.addRule(RelativeLayout.CENTER_VERTICAL);

            // itemTitle.setLayoutParams(layout);
            itemTitle.setGravity(Gravity.LEFT);
            itemTitle.setPadding(leftRightItem, 0, leftRightItem, 0);
            itemTitle.setText(historyDevices[i]);

            singleItemLayout.addView(itemTitle, layout);

            final CheckBox itemCheck = new CheckBox(activity);

            layout = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
            layout.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
            layout.addRule(RelativeLayout.CENTER_VERTICAL);

            // itemCheck.setLayoutParams(layout);

            itemCheck.setGravity(Gravity.RIGHT);
            itemCheck.setPadding(leftRightItem, 0, leftRightItem, 0);
            itemCheck.setOnClickListener(null);
            itemCheck.setClickable(false);
            itemCheck.setId(i + historyDevices.length);

            if (devicesToShow.isEmpty() || devicesToShow.contains(historyDevices[i]))
                itemCheck.setChecked(true);
            else
                itemCheck.setChecked(false);

            singleItemLayout.addView(itemCheck, layout);

            // layout = new
            // RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,
            // RelativeLayout.LayoutParams.WRAP_CONTENT);

            // singleItemLayout.setLayoutParams(layout);

            singleItemLayout.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(final View v) {
                    final CheckBox check = (CheckBox) v.findViewById(v.getId() + historyDevices.length);
                    if (check.isChecked()) {
                        check.setChecked(false);
                        devicesToShow.remove(historyDevices[v.getId()]);
                    } else {
                        check.setChecked(true);
                        devicesToShow.add(historyDevices[v.getId()]);
                    }

                }

            });

            deviceListView.addView(singleItemLayout);

            final View divider = new View(activity);

            layout = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, heightDiv);

            divider.setBackgroundResource(R.drawable.bg_trans_light_10);

            deviceListView.addView(divider, layout);

        }
        deviceListView.invalidate();
    }

    final String historyNetworks[] = activity.getHistoryFilterNetworks();

    if (historyNetworks != null) {

        for (int i = 0; i < historyNetworks.length; i++) {

            final RelativeLayout singleItemLayout = new RelativeLayout(activity); // (LinearLayout)measurememtItemView.findViewById(R.id.measurement_item);

            singleItemLayout.setId(i);
            singleItemLayout.setClickable(true);
            singleItemLayout.setBackgroundResource(R.drawable.list_selector);

            singleItemLayout.setLayoutParams(
                    new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));

            final TextView itemTitle = new TextView(activity, null, R.style.textMediumLight);
            RelativeLayout.LayoutParams layout = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                    LayoutParams.MATCH_PARENT);
            layout.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
            layout.addRule(RelativeLayout.CENTER_VERTICAL);

            // itemTitle.setLayoutParams(layout);
            itemTitle.setGravity(Gravity.LEFT);
            itemTitle.setPadding(leftRightItem, 0, leftRightItem, 0);
            itemTitle.setText(historyNetworks[i]);

            singleItemLayout.addView(itemTitle, layout);

            final CheckBox itemCheck = new CheckBox(activity);

            layout = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
            layout.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
            layout.addRule(RelativeLayout.CENTER_VERTICAL);

            // itemCheck.setLayoutParams(layout);

            itemCheck.setGravity(Gravity.RIGHT);
            itemCheck.setPadding(leftRightItem, 0, leftRightItem, 0);
            itemCheck.setOnClickListener(null);
            itemCheck.setClickable(false);
            itemCheck.setId(i + historyNetworks.length);

            if (networksToShow.isEmpty() || networksToShow.contains(historyNetworks[i]))
                itemCheck.setChecked(true);
            else
                itemCheck.setChecked(false);

            singleItemLayout.addView(itemCheck, layout);

            singleItemLayout.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(final View v) {
                    final CheckBox check = (CheckBox) v.findViewById(v.getId() + historyNetworks.length);
                    if (check.isChecked()) {
                        check.setChecked(false);
                        networksToShow.remove(historyNetworks[v.getId()]);
                    } else {
                        check.setChecked(true);
                        networksToShow.add(historyNetworks[v.getId()]);
                    }
                    System.out.println(networksToShow.toString());
                }

            });

            networkListView.addView(singleItemLayout);

            final View divider = new View(activity);

            layout = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, heightDiv);

            divider.setBackgroundResource(R.drawable.bg_trans_light_10);

            networkListView.addView(divider, layout);

        }
        networkListView.invalidate();
    }
    /*
     * // Set option as Multiple Choice. So that user can able to select
     * more the one option from list deviceListView.setAdapter(new
     * ArrayAdapter<String>(activity,
     * android.R.layout.simple_list_item_multiple_choice, historyDevices));
     * deviceListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
     * 
     * for (int i = 0; i < historyDevices.length; i++) {
     * //deviceListView.setItemChecked(i, true); }
     * 
     * deviceListView.setOnItemClickListener(new OnItemClickListener() {
     * 
     * @Override public void onItemClick(AdapterView<?> l, View v, int
     * position, long id) {
     * 
     * }
     * 
     * });
     * 
     * 
     * // Set option as Multiple Choice. So that user can able to select
     * more the one option from list networkListView.setAdapter(new
     * ArrayAdapter<String>(activity,
     * android.R.layout.simple_list_item_multiple_choice, networkDevices));
     * networkListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
     * 
     * for (int i = 0; i < networkDevices.length; i++) {
     * networkListView.setItemChecked(i, true); }
     * 
     * SparseBooleanArray checked =
     * deviceListView.getCheckedItemPositions(); ArrayList<String>
     * devicesToShow = new ArrayList<String>(); for(int i = 0; i <
     * checked.size()+1; i++){ if(checked.get(i))
     * devicesToShow.add(historyDevices[i]); }
     */

    return view;
}

From source file:io.github.douglasjunior.androidSimpleTooltip.SimpleTooltip.java

private void createOverlay(final ViewGroup rootView) {
    mOverlay = mTransparentOverlay ? new View(mContext) : new OverlayView(mContext, mAnchorView);
    mOverlay.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
    mOverlay.setOnTouchListener(mOverlayTouchListener);
    rootView.addView(mOverlay);/*  w w w  . j ava2 s. co  m*/
}