Example usage for android.view ViewGroup addView

List of usage examples for android.view ViewGroup addView

Introduction

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

Prototype

public void addView(View child) 

Source Link

Document

Adds a child view.

Usage

From source file:com.example.pagergallerysample.PagerGalleryAdapter.java

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

    View root = mInflater.inflate(R.layout.item, null);
    ImageView img = (ImageView) root.findViewById(R.id.item_img);
    Resources res = mContext.get().getResources();
    int resId = res.getIdentifier("item" + (position + 1), "drawable", mContext.get().getPackageName());
    img.setImageResource(resId);//from  www .  j  a  va 2 s  .c  o  m
    TextView txt = (TextView) root.findViewById(R.id.item_label);
    txt.setText("item " + (position + 1));
    RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(100,
            RelativeLayout.LayoutParams.MATCH_PARENT);
    root.setLayoutParams(lp);
    container.addView(root);
    return root;
}

From source file:com.todoroo.astrid.actfm.TagViewFragment.java

@Override
protected View getListBody(ViewGroup root) {
    ViewGroup parent = (ViewGroup) getActivity().getLayoutInflater().inflate(R.layout.task_list_body_tag, root,
            false);/*from  w  w  w. jav a2 s.  c o  m*/

    taskListView = super.getListBody(parent);
    parent.addView(taskListView);

    return parent;
}

From source file:com.digi.android.wva.fragments.ChartFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Add chart view to container
    if (container == null) {
        container = new LinearLayout(getActivity());
    }/*from  w w w .ja va2s .  c  o m*/
    container.addView(ChartFactory.getCombinedXYChartView(getActivity(), mDataset, mRenderer,
            new String[] { LineChart.TYPE, LineChart.TYPE }));
    return container;
}

From source file:android.support.v7.app.ActionBarActivityDelegateBase.java

@Override
public void setContentView(View v) {
    ensureSubDecor();/* w ww.j a  v  a  2 s .  c o  m*/
    if (mHasActionBar) {
        final ViewGroup contentParent = (ViewGroup) mActivity.findViewById(R.id.action_bar_activity_content);
        contentParent.removeAllViews();
        contentParent.addView(v);
    } else {
        mActivity.superSetContentView(v);
    }
}

From source file:com.amazon.android.ui.fragments.ErrorDialogFragment.java

/**
 * Generate the buttons dynamically.//w  ww. ja  v  a 2 s . c om
 *
 * @param actionLabels   The list containing the text to be displayed on the action buttons.
 * @param errorButtonRow The view group containing the buttons.
 */
private void createAndConfigureActionButtons(List<String> actionLabels, ViewGroup errorButtonRow) {

    Button button;

    int buttonPosition = 0;
    for (String actionLabel : actionLabels) {
        if (mButtonsList == null) {
            mButtonsList = new ArrayList<>();
        }
        // Create the button with the correct text.
        button = createActionButton(actionLabel);
        // Add the button to the layout.
        errorButtonRow.addView(button);
        // Set the left focus for the buttons.
        setLeftFocus(button, mButtonsList, buttonPosition);
        if (buttonPosition == 0) {
            button.requestFocus();
        }
        buttonPosition++;
        // Add the button to the button list.
        mButtonsList.add(button);
    }
    // Set the right focus for the buttons.
    setRightFocus(mButtonsList);
}

From source file:com.mirasense.scanditsdk.plugin.ScanditSDK.java

private void scan(JSONArray data) {
    if (mPendingOperation) {
        return;/*  ww  w.j  ava  2s  .c o  m*/
    }
    mPendingOperation = true;
    mHandler.start();

    final Bundle bundle = new Bundle();
    try {
        bundle.putString(ScanditSDKParameterParser.paramAppKey, data.getString(0));
    } catch (JSONException e) {
        Log.e("ScanditSDK", "Function called through Java Script contained illegal objects.");
        e.printStackTrace();
        return;
    }

    if (data.length() > 1) {
        // We extract all options and add them to the intent extra bundle.
        try {
            setOptionsOnBundle(data.getJSONObject(1), bundle);
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }

    if (bundle.containsKey(ScanditSDKParameterParser.paramContinuousMode)) {
        mContinuousMode = bundle.getBoolean(ScanditSDKParameterParser.paramContinuousMode);
    }

    ScanditLicense.setAppKey(bundle.getString(ScanditSDKParameterParser.paramAppKey));
    ScanditSDKGlobals.usedFramework = "phonegap";

    if (bundle.containsKey(ScanditSDKParameterParser.paramPortraitMargins)
            || bundle.containsKey(ScanditSDKParameterParser.paramLandscapeMargins)) {
        cordova.getActivity().runOnUiThread(new Runnable() {
            public void run() {
                ScanSettings settings = ScanditSDKParameterParser.settingsForBundle(bundle);
                mBarcodePicker = new SearchBarBarcodePicker(cordova.getActivity(), settings);
                mBarcodePicker.setOnScanListener(ScanditSDK.this);
                mBarcodePicker.setOnSearchBarListener(ScanditSDK.this);
                mLayout = new RelativeLayout(cordova.getActivity());

                ViewGroup viewGroup = getViewGroupToAddTo();
                if (viewGroup != null) {
                    viewGroup.addView(mLayout);
                }

                Display display = cordova.getActivity().getWindowManager().getDefaultDisplay();
                ScanditSDKParameterParser.updatePickerUIFromBundle(mBarcodePicker, bundle, display.getWidth(),
                        display.getHeight());

                RelativeLayout.LayoutParams rLayoutParams = new RelativeLayout.LayoutParams(
                        RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
                mLayout.addView(mBarcodePicker, rLayoutParams);
                adjustLayout(bundle, 0);

                if (bundle.containsKey(ScanditSDKParameterParser.paramPaused)
                        && bundle.getBoolean(ScanditSDKParameterParser.paramPaused)) {
                    mBarcodePicker.startScanning(true);
                } else {
                    mBarcodePicker.startScanning();
                }
            }
        });

    } else {
        ScanditSDKResultRelay.setCallback(this);
        Intent intent = new Intent(cordova.getActivity(), ScanditSDKActivity.class);
        intent.putExtras(bundle);
        cordova.startActivityForResult(this, intent, 1);
    }
}

From source file:com.activiti.android.ui.form.FormManager.java

private View generateOutcome(ViewGroup hookView, String name, LayoutInflater li) {
    View vr = li.inflate(R.layout.form_outcome, null);
    ((Button) vr.findViewById(R.id.outcome_button)).setText(name);
    hookView.addView(vr);
    return vr;//from w  ww  .  ja va  2 s.c  o  m
}

From source file:co.bytera.twodimensionalviewpager.adapter.TwoDimensionalViewPagerAdapter.java

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

    @SuppressWarnings("static-access")
    LayoutInflater inflater = (LayoutInflater) context.getSystemService(context.LAYOUT_INFLATER_SERVICE);

    /*//from ww w .ja  va 2  s .  c om
     * Layout is created from xml here, but it can be done by java coding as well
     */
    View view = inflater.inflate(R.layout.view_page, null);

    TextView textView = (TextView) view.findViewById(R.id.textView1);
    textView.setText(rowNumber + ", " + position);

    ImageView imageView = (ImageView) view.findViewById(R.id.imageView1);
    imageView.setImageResource(data[rowNumber][position]);

    container.addView(view);

    return view;
}

From source file:com.philliphsu.clock2.ringtone.TimesUpActivity.java

@Override
protected void getHeaderContent(ViewGroup parent) {
    // Inflate the content and apply the parent's layout params, but don't
    // attach it to the parent yet. This is so the return value can be
    // the root of the inflated content, and not the parent. Alternatively,
    // we could set an id on the root of the content's layout and find it
    // from the returned parent.
    CountdownChronometer countdown = (CountdownChronometer) getLayoutInflater()
            .inflate(R.layout.content_header_timesup_activity, parent, false);
    countdown.setBase(SystemClock.elapsedRealtime());
    countdown.start();/*  ww w.  j  a  va 2 s.  c  o m*/
    parent.addView(countdown);
}

From source file:com.ubiLive.GameCloud.activity.MainActivity.java

private GCVideoView initVideoPage(ViewGroup root) {
    GCVideoView videoView = new GCVideoView(MainActivity.this);
    videoView.setVideoSize(Utils.getScreenWidth(MainActivity.this), Utils.getScreenHeight(MainActivity.this));
    root.addView(videoView);
    return videoView;
}