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:org.zywx.wbpalmstar.plugin.inputtextfieldview.ACEInputTextFieldView.java

public ACEInputTextFieldView(Context context, JSONObject params, EUExInputTextFieldView uexBaseObj) {
    super(context);
    this.setOrientation(VERTICAL);
    mUexBaseObj = uexBaseObj;//ww w.  j  a v  a 2 s .c  o  m
    CRes.init(getContext().getApplicationContext());
    mInputManager = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);

    View inputLayout = LayoutInflater.from(getContext()).inflate(CRes.plugin_inputtextfieldview_layout, null,
            false);
    mOutOfTouchView = new View(getContext());
    LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT, 0);
    lp.weight = 1;
    LayoutParams lp2 = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    lp2.gravity = Gravity.BOTTOM;

    this.addView(mOutOfTouchView, lp);
    this.addView(inputLayout, lp2);

    initView();
    initKeyboardParams(params);
    initEvent();

    initPagerIndicator();
    initLayoutTransition();
}

From source file:com.cocosw.accessory.views.layout.CollapsingTitleLayout.java

@Override
public void addView(View child, int index, ViewGroup.LayoutParams params) {
    super.addView(child, index, params);

    if (child.getClass().getName().endsWith(".Toolbar")) {
        mToolbar = (ViewGroup) child;/*from  w  w w .  j a  v  a2  s.c  o m*/
        mDummyView = new View(getContext());
        mToolbar.addView(mDummyView, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    }
}

From source file:com.metinkale.prayerapp.vakit.fragments.MainFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bdl) {
    mView = inflater.inflate(R.layout.vakit_fragment, container, false);
    setHasOptionsMenu(true);//  ww  w .  j  a  v  a 2  s  . com
    if (mCity == 0) {
        return mView;
    }

    mCountdown = (TextView) mView.findViewById(R.id.countdown);
    mTitle = (TextView) mView.findViewById(R.id.city);
    mDate = (TextView) mView.findViewById(R.id.date);
    mHicri = (TextView) mView.findViewById(R.id.hicri);

    mKerahat = (TextView) mView.findViewById(R.id.kerahat);

    mTimes = Times.getTimes(mCity);

    if (mTimes == null) {
        return new View(getActivity());
    }
    ImageView source1 = (ImageView) mView.findViewById(R.id.source1);
    ImageView source2 = (ImageView) mView.findViewById(R.id.source2);
    if (mTimes.getSource().resId != 0) {
        source1.setImageResource(mTimes.getSource().resId);
        source2.setImageResource(mTimes.getSource().resId);
    }

    if (Prefs.useArabic()) {
        for (int i = 0; i < idsNames.length; i++) {
            TextView tv = (TextView) mView.findViewById(idsNames[i]);
            tv.setGravity(Gravity.LEFT);
            tv.setText(Vakit.getByIndex(i).getString());
        }
    }

    return mView;
}

From source file:com.probam.updater.MainActivity.java

private void addTab(String id, int resId) {
    TabHost.TabSpec tabSpec = mTabHost.newTabSpec(id);
    tabSpec.setIndicator(getResources().getString(resId));
    tabSpec.setContent(new TabContentFactory() {

        @Override/*from w  w  w .j a  v a 2 s . c o  m*/
        public View createTabContent(String tag) {
            View v = new View(MainActivity.this);
            v.setMinimumWidth(0);
            v.setMinimumHeight(0);
            return v;
        }
    });
    mTabHost.addTab(tabSpec);
}

From source file:com.tmall.wireless.tangram3.BaseTangramEngine.java

public BaseTangramEngine(@NonNull final Context context, @NonNull final DataParser<O, T> dataParser,
        @NonNull final IAdapterBuilder<Card, BaseCell> adapterBuilder) {
    //noinspection ConstantConditions
    Preconditions.checkArgument(context != null, "context is null");
    this.mContext = context;
    this.mLayoutManager = new VirtualLayoutManager(mContext);

    this.mLayoutManager.setLayoutViewFactory(new LayoutViewFactory() {
        @Override//ww  w .  j av  a 2 s  .  co  m
        public View generateLayoutView(@NonNull Context context) {
            ImageView imageView = ImageUtils.createImageInstance(context);
            return imageView != null ? imageView : new View(context);
        }
    });

    this.mDataParser = Preconditions.checkNotNull(dataParser, "dataParser in constructor should not be null");
    this.mAdapterBuilder = Preconditions.checkNotNull(adapterBuilder,
            "adapterBuilder in constructor should not be null");
}

From source file:com.cytmxk.test.animation.ViewPagerTabs.java

private void addTab(CharSequence tabTitle, final int position) {
    View tabView;/* w w  w  .java  2s.c o  m*/
    if (mTabIcons != null && position < mTabIcons.length) {
        View iconView = new View(getContext());
        iconView.setBackgroundResource(mTabIcons[position]);
        iconView.setContentDescription(tabTitle);

        tabView = iconView;
    } else {
        final TextView textView = new TextView(getContext());
        textView.setText(tabTitle);
        textView.setBackgroundResource(R.drawable.view_pager_tab_background);

        // Assign various text appearance related attributes to child views.
        if (mTextStyle > 0) {
            textView.setTypeface(textView.getTypeface(), mTextStyle);
        }
        if (mTextSize > 0) {
            textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTextSize);
        }
        if (mTextColor != null) {
            textView.setTextColor(mTextColor);
        }
        textView.setAllCaps(mTextAllCaps);
        textView.setGravity(Gravity.CENTER);

        tabView = textView;
    }

    tabView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            mPager.setCurrentItem(getRtlPosition(position));
        }
    });

    tabView.setOnLongClickListener(new OnTabLongClickListener(position));

    tabView.setPadding(mSidePadding, 0, mSidePadding, 0);
    mTabStrip.addView(tabView, new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1));

    // Default to the first child being selected
    if (position == 0) {
        mPrevSelected = 0;
        tabView.setSelected(true);
    }
}

From source file:com.misczak.joinmybridge.PhoneBookFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    listView = (DynamicListView) getActivity().findViewById(android.R.id.list);

    //Set up the List View to not show lines between cards

    listView.setDivider(null);//from   www.j  ava2  s  .co  m
    listView.setDividerHeight(DIVIDER_HEIGHT);
    listView.setHeaderDividersEnabled(true);
    listView.setFooterDividersEnabled(true);
    listView.addHeaderView(new View(getActivity()));
    listView.addFooterView(new View(getActivity()));

    buildAdapter(mBridgeList);

    /*
    listView.enableDragAndDrop();
    listView.setDraggableManager(new TouchViewDraggableManager(R.id.draganddrop_grip));
    listView.setOnItemMovedListener(new MyOnItemMovedListener(adapter));
    listView.setOnItemLongClickListener(new MyOnItemLongClickListener(listView));
    */

}

From source file:fr.cph.stock.android.activity.AccountActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    Log.v(TAG, "Account Activity onCreate");
    super.onCreate(savedInstanceState);
    setContentView(R.layout.account_activity);

    Bundle b = getIntent().getExtras();//from  w w  w. ja  v  a2s.  c o m
    portfolio = b.getParcelable("portfolio");

    errorView = (TextView) findViewById(R.id.errorMessage);
    totalValueView = (TextView) findViewById(R.id.totalValue);
    totalGainView = (TextView) findViewById(R.id.totalGain);
    totalPlusMinusValueView = (TextView) findViewById(R.id.totalPlusMinusValue);
    lastUpateView = (TextView) findViewById(R.id.lastUpdate);
    liquidityView = (TextView) findViewById(R.id.liquidity);
    yieldYearView = (TextView) findViewById(R.id.yieldYear);
    shareValueView = (TextView) findViewById(R.id.shareValue);
    gainView = (TextView) findViewById(R.id.gain2);
    perfView = (TextView) findViewById(R.id.perf);
    yieldView = (TextView) findViewById(R.id.yieldPerf);
    taxesView = (TextView) findViewById(R.id.taxes);

    RelativeLayout accLayout = (RelativeLayout) findViewById(R.id.accountsLayout);
    TextView recent = new TextView(getApplicationContext());
    textViews = new ArrayList<TextView>();
    int id = 1;
    int nameID = 100;
    int viewId1 = 500;
    int currencyId = 1000;
    for (int i = 0; i < portfolio.getAccounts().size(); i++) {
        Account account = portfolio.getAccounts().get(i);
        TextView currentAccountNameTextView = new TextView(getApplicationContext());
        currentAccountNameTextView.setText(account.getName());
        currentAccountNameTextView.setTextColor(Color.GRAY);
        currentAccountNameTextView.setId(nameID);
        RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams((int) LayoutParams.WRAP_CONTENT,
                (int) LayoutParams.WRAP_CONTENT);
        if (i != 0) {
            params.addRule(RelativeLayout.BELOW, recent.getId());
        }
        params.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
        currentAccountNameTextView.setLayoutParams(params);
        accLayout.addView(currentAccountNameTextView, params);
        textViews.add(currentAccountNameTextView);

        View viewPoint1 = new View(getApplicationContext());
        viewPoint1.setId(viewId1);
        viewPoint1.setBackgroundColor(getResources().getColor(R.color.grey_light));
        params = new RelativeLayout.LayoutParams((int) LayoutParams.MATCH_PARENT, 2);
        params.addRule(RelativeLayout.RIGHT_OF, nameID);
        params.addRule(RelativeLayout.LEFT_OF, currencyId);
        params.setMargins(0, Util.convertDpToPxl(15, getApplicationContext()), 0, 0);
        if (i != 0) {
            params.addRule(RelativeLayout.BELOW, recent.getId());
        }
        viewPoint1.setLayoutParams(params);
        accLayout.addView(viewPoint1, params);

        TextView currentCurrencyTextView = new TextView(getApplicationContext());
        currentCurrencyTextView.setText(account.getCurrency());
        currentCurrencyTextView.setTextColor(Color.GRAY);
        currentCurrencyTextView.setId(currencyId);
        params = new RelativeLayout.LayoutParams((int) LayoutParams.WRAP_CONTENT,
                (int) LayoutParams.WRAP_CONTENT);
        params.addRule(RelativeLayout.CENTER_HORIZONTAL);
        if (i != 0) {
            params.addRule(RelativeLayout.BELOW, recent.getId());
        }
        currentCurrencyTextView.setLayoutParams(params);
        accLayout.addView(currentCurrencyTextView, params);
        textViews.add(currentCurrencyTextView);

        View viewPoint2 = new View(getApplicationContext());
        viewPoint2.setBackgroundColor(getResources().getColor(R.color.grey_light));
        params = new RelativeLayout.LayoutParams((int) LayoutParams.MATCH_PARENT, 2);
        params.addRule(RelativeLayout.RIGHT_OF, currencyId);
        params.addRule(RelativeLayout.LEFT_OF, id);
        params.setMargins(0, Util.convertDpToPxl(15, getApplicationContext()), 0, 0);
        if (i != 0) {
            params.addRule(RelativeLayout.BELOW, recent.getId());
        }
        viewPoint2.setLayoutParams(params);
        accLayout.addView(viewPoint2, params);

        TextView currentTextView = new TextView(getApplicationContext());
        currentTextView.setText(account.getLiquidity());
        currentTextView.setTextColor(Color.GRAY);
        currentTextView.setId(id);
        params = new RelativeLayout.LayoutParams((int) LayoutParams.WRAP_CONTENT,
                (int) LayoutParams.WRAP_CONTENT);
        if (i != 0) {
            params.addRule(RelativeLayout.BELOW, recent.getId());
        }
        params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
        currentTextView.setLayoutParams(params);
        recent = currentTextView;
        accLayout.addView(currentTextView, params);
        textViews.add(currentTextView);

        id++;
        nameID++;
        viewId1++;
        currencyId++;
    }
    buildUi(false);
    // Set context
    EasyTracker.getInstance().setContext(getApplicationContext());
    // Instantiate the Tracker
    tracker = EasyTracker.getTracker();
}

From source file:com.csounds.examples.tests.SynthActivity.java

/** Called when the activity is first created. */
@Override/*  w w  w.  j  ava2 s.  c  om*/
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    for (int i = 0; i < touchIds.length; i++) {
        touchIds[i] = -1;
        touchX[i] = -1;
        touchY[i] = -1;
    }
    multiTouchView = new View(this);

    setContentView(R.layout.synth2);
    multiTouchView = (RelativeLayout) findViewById(R.id.synth);
    octPlusButton = (Button) findViewById(R.id.plusoctavebutton);
    octMinusButton = (Button) findViewById(R.id.minusoctavebutton);
    diode4 = (ToggleButton) findViewById(R.id.diode4);
    diode3 = (ToggleButton) findViewById(R.id.diode3);
    LcdScreenView lcd = (LcdScreenView) findViewById(R.id.lcd_screen);
    new DrumMachineLcdUpdater(lcd.getModel());
    this.createLoadListener((View) lcd);
    keyboardLayout = (RelativeLayout) findViewById(R.id.keyboard);
    keyboardLayout.setOnTouchListener(new OnTouchListener() {

        /* (non-Javadoc)
         * @see android.view.View.OnTouchListener#onTouch(android.view.View, android.view.MotionEvent)
         */
        public boolean onTouch(View v, MotionEvent event) {
            final int action = event.getAction() & MotionEvent.ACTION_MASK;
            float[] touchArrayDown = new float[2];
            switch (action) {
            case MotionEvent.ACTION_DOWN:
            case MotionEvent.ACTION_POINTER_DOWN:

                for (int i = 0; i < event.getPointerCount(); i++) {
                    int pointerId = event.getPointerId(i);
                    int id = getTouchId(pointerId);

                    if (id == -1) {

                        id = getTouchIdAssignment();

                        if (id != -1) {
                            touchIds[id] = pointerId;
                            touchX[id] = event.getX(i) / keyboardLayout.getWidth();
                            touchY[id] = 1 - (event.getY(i) / keyboardLayout.getHeight());
                            //TODO calculte interval Y

                            if (touchXPtr[id] != null) {
                                //TODO swtich touchid
                                //                           Log.d("touchXtouchY","touchX[id]) " + touchX[id] + " touchY[id]) " + touchY[id] + " multitouchview width " + multiTouchView.getWidth() + " multitouchview width " + multiTouchView.getHeight());
                                //                           Log.d("touchXtouchY","keyboardLayout width " + keyboardLayout.getWidth() + " keyboardLayout width " + keyboardLayout.getHeight());
                                // get the key from the touch coordinates
                                float[] touchArray = new float[2];
                                touchArray = evaluateTouchKey(touchX[id], touchY[id]);
                                touchArrayDown[0] = touchX[id];
                                touchArrayDown[1] = touchY[id];
                                touchX[id] = touchArray[0];
                                touchY[id] = touchArray[1];

                                //                           Log.d("touchXtouchY","touchX[id]) " + touchX[id] + " touchY[id]) " + touchY[id]);
                                touchXPtr[id].SetValue(0, touchX[id]);
                                touchYPtr[id].SetValue(0, touchY[id]);
                                csoundObj.sendScore(String.format("i1.%d 0 -2 %d", id, id));
                            }

                        }
                    }

                }

                break;
            case MotionEvent.ACTION_MOVE:

                for (int i = 0; i < event.getPointerCount(); i++) {
                    int pointerId = event.getPointerId(i);
                    int id = getTouchId(pointerId);

                    if (id != -1) {
                        touchIds[id] = pointerId;
                        touchX[id] = event.getX(i) / keyboardLayout.getWidth();
                        touchY[id] = 1 - (event.getY(i) / keyboardLayout.getHeight());
                        //TODO calculte interval Y

                        if (touchXPtr[id] != null) {
                            //TODO swtich touchid
                            //                           Log.d("aaa","touchX[id]) " + touchX[id] + " touchY[id]) " + touchY[id] + " multitouchview width " + multiTouchView.getWidth() + " multitouchview width " + multiTouchView.getHeight());
                            //                           Log.d("aaa","keyboardLayout width " + keyboardLayout.getWidth() + " keyboardLayout width " + keyboardLayout.getHeight());
                            // get the key from the touch coordinates
                            float[] touchArray = new float[2];

                            touchArray = evaluateTouchKey(touchX[id], touchY[id]);

                            touchX[id] = touchArray[0];
                            touchY[id] = touchArray[1];

                            //                           Log.d("touchXtouchY","touchX[id]) " + touchX[id] + " touchY[id]) " + touchY[id]);
                            touchXPtr[id].SetValue(0, touchX[id]);
                            touchYPtr[id].SetValue(0, touchY[id]);
                            csoundObj.sendScore(String.format("i1.%d 0 -2 %d", id, id));
                        }

                    }

                }
                break;

            case MotionEvent.ACTION_POINTER_UP:
            case MotionEvent.ACTION_UP: {
                int activePointerIndex = event.getActionIndex();
                int pointerId = event.getPointerId(activePointerIndex);

                int id = getTouchId(pointerId);
                if (id != -1) {
                    touchIds[id] = -1;
                    csoundObj.sendScore(String.format("i-1.%d 0 0 %d", id, id));
                }
                //write file
                /*         System.out.println(String.format(
                      "i1.%d 0 -2 %d", id, id));
                writeToFile(String.format(
                      "i1.%d 0 -2 %d", id, id));
                 */
            }
                break;
            }

            return true;
        }

    });

    OnTouchListener octBtnOk = new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            switch (event.getAction()) {
            case MotionEvent.ACTION_DOWN:
                if (octNbr < 12)
                    octNbr += 12;
                break;
            }
            return false;
        }
    };
    octPlusButton.setOnTouchListener(octBtnOk);

    OnTouchListener octBtnMinus = new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            switch (event.getAction()) {
            case MotionEvent.ACTION_DOWN:
                if (octNbr > -36)
                    octNbr -= 12;

                break;
            }
            return false;
        }
    };

    octMinusButton.setOnTouchListener(octBtnMinus);

    String csd = getResourceFileAsString(R.raw.multitouch_xy_kx);
    File f = createTempFile(csd);

    csoundObj.addBinding(this);

    csoundObj.startCsound(f);
    //   initknobs();

    initSeekBar(diode3, diode4);

}

From source file:com.odoo.base.login_signup.SyncWizard.java

private void generateLayout() {

    LinearLayout layout = (LinearLayout) rootView.findViewById(R.id.layoutLoginConfig);
    SyncWizardValues syncValues = new SyncWizardValues();
    List<SyncValue> syncValuesList = syncValues.syncValues();
    if (syncValuesList.size() == 0) {
        getActivity().finish();//w  w  w. j a va  2  s  .  co m
        getActivity().startActivity(getActivity().getIntent());
    }
    checkbox = new CheckBox[syncValuesList.size()];
    rdoGroups = new RadioGroup[syncValuesList.size()];
    TextView[] txvTitles = new TextView[syncValuesList.size()];
    int i = 0;
    int id = 1;
    Typeface tf_light = Typeface.create("sans-serif-light", 0);
    Typeface tf_bold = Typeface.create("sans-serif-condensed", 0);
    for (SyncValue value : syncValuesList) {
        if (!value.getIsGroup()) {
            if (value.getType() == SyncValue.Type.CHECKBOX) {
                checkbox[i] = new CheckBox(scope.context());
                checkbox[i].setId(id);
                checkbox[i].setText(value.getTitle());
                checkbox[i].setTypeface(tf_light);
                layout.addView(checkbox[i]);
            } else {
                rdoGroups[i] = new RadioGroup(scope.context());
                rdoGroups[i].setId(i + 50);
                RadioButton[] rdoButtons = new RadioButton[value.getRadioGroups().size()];
                int mId = 1;
                int j = 0;
                for (SyncValue rdoVal : value.getRadioGroups()) {
                    rdoButtons[j] = new RadioButton(scope.context());
                    rdoButtons[j].setId(mId);
                    rdoButtons[j].setText(rdoVal.getTitle());
                    rdoButtons[j].setTypeface(tf_light);
                    rdoGroups[i].addView(rdoButtons[j]);
                    mId++;
                    j++;
                }
                layout.addView(rdoGroups[i]);
            }
            authorities.put(id + "", value.getAuthority());
            i++;
            id++;
        } else {
            txvTitles[i] = new TextView(scope.context());
            txvTitles[i].setId(id);
            txvTitles[i].setText(value.getTitle());
            txvTitles[i].setAllCaps(true);
            txvTitles[i].setPadding(0, 5, 0, 3);
            txvTitles[i].setTypeface(tf_bold);
            layout.addView(txvTitles[i]);
            View lineView = new View(scope.context());
            lineView.setBackgroundColor(Color.parseColor("#BEBEBE"));
            lineView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, 1));
            layout.addView(lineView);
        }
    }
}