android.widget.LinearLayout#getContext ( )源码实例Demo

下面列出了android.widget.LinearLayout#getContext ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: LoopBanner   文件: JDIndicatorAdapter.java
@Override
public void addIndicator(LinearLayout container, Drawable drawable, int size, int margin) {
    drawable = ContextCompat.getDrawable(container.getContext(), drawableId);
    if (drawable == null) {
        throw new IllegalArgumentException("please provide valid drawableId");
    }
    ImageView image = new ImageView(container.getContext());
    ViewCompat.setBackground(image, drawable);
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
            LinearLayout.LayoutParams.WRAP_CONTENT);
    params.leftMargin = margin;
    container.addView(image, params);

    computeScale(drawable.getMinimumWidth(), margin);

}
 
@Override
public View produceLayout(LayoutInflater inflater, @Nullable ViewGroup container) {
    LinearLayout parent = new LinearLayout(inflater.getContext());
    parent.setLayoutParams(new ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT));
    parent.setOrientation(VERTICAL);

    View child = origin.produceLayout(inflater, parent);
    LinearLayout.LayoutParams childParams = new LinearLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT);
    if (includeBottomBar) {
        childParams.weight = 1;
    }

    if (includeToolbar) {
        inflater.inflate(R.layout.toolbar, parent);
    }
    parent.addView(child, childParams);
    if (includeBottomBar) {
        AHBottomNavigation bottomNavigation = new AHBottomNavigation(parent.getContext());
        bottomNavigation.setId(R.id.bottomNavigation);
        parent.addView(
                bottomNavigation,
                new LinearLayout.LayoutParams(MATCH_PARENT, (int) dp(parent.getContext(), 56)));
    }

    return parent;
}
 
源代码3 项目: AndroidChromium   文件: PaymentRequestSection.java
@Override
protected void createMainSectionContent(LinearLayout mainSectionLayout) {
    Context context = mainSectionLayout.getContext();

    // Add a label that will be used to indicate that the total cart price has been updated.
    addUpdateText(mainSectionLayout);

    // The breakdown is represented by an end-aligned GridLayout that takes up only as much
    // space as it needs.  The GridLayout ensures a consistent margin between the columns.
    mBreakdownLayout = new GridLayout(context);
    mBreakdownLayout.setColumnCount(2);
    LayoutParams breakdownParams =
            new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    breakdownParams.gravity = Gravity.END;
    mainSectionLayout.addView(mBreakdownLayout, breakdownParams);
}
 
源代码4 项目: geopaparazzi   文件: NoEditableLayerToolGroup.java
public void onClick(View v) {
    if (v == selectAllButton) {
        Tool currentTool = EditManager.INSTANCE.getActiveTool();
        if (currentTool instanceof InfoTool) {
            // if the same tool is re-selected, it is disabled
            EditManager.INSTANCE.setActiveTool(null);
        } else {
            // check maps enablement
            try {
                List<IVectorDbLayer> enabledVectorLayers = LayerManager.INSTANCE.getEnabledVectorLayers(mapView);
                if (enabledVectorLayers.size() == 0) {
                    LinearLayout parent = EditManager.INSTANCE.getToolsLayout();
                    if (parent != null) {
                        Context context = parent.getContext();
                        GPDialogs.warningDialog(context, context.getString(R.string.no_queriable_layer_is_visible), null);
                    }
                    return;
                }
            } catch (Exception e) {
                GPLog.error(this, null, e);
            }

            Tool activeTool = new InfoTool(this, mapView);
            EditManager.INSTANCE.setActiveTool(activeTool);
        }
    }

    handleToolIcons(v);
}
 
源代码5 项目: AndroidAPS   文件: SWEventListener.java
@Override
public void generateDialog(LinearLayout layout) {
    Context context = layout.getContext();

    textView = new TextView(context);
    textView.setId(layout.generateViewId());
    textView.setText((textLabel != 0 ? MainApp.gs(textLabel) : "") + " " + status);
    layout.addView(textView);
}
 
源代码6 项目: AndroidAPS   文件: TriggerConnector.java
@Override
public void generateDialog(LinearLayout root, FragmentManager fragmentManager) {
    final int padding = MainApp.dpToPx(5);

    root.setPadding(padding, padding, padding, padding);
    root.setBackgroundResource(R.drawable.border_automation_unit);

    LinearLayout triggerListLayout = new LinearLayout(root.getContext());
    triggerListLayout.setOrientation(LinearLayout.VERTICAL);
    triggerListLayout.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    root.addView(triggerListLayout);

    adapter = new TriggerListAdapter(fragmentManager, root.getContext(), triggerListLayout, this);
}
 
源代码7 项目: 365browser   文件: PaymentRequestSection.java
@Override
protected void createMainSectionContent(LinearLayout mainSectionLayout) {
    Context context = mainSectionLayout.getContext();

    mExtraTextViews = new TextView[3];
    for (int i = 0; i < mExtraTextViews.length; i++) {
        mExtraTextViews[i] = new TextView(context);
        ApiCompatibilityUtils.setTextAppearance(
                mExtraTextViews[i], R.style.PaymentsUiSectionDefaultText);
        mainSectionLayout.addView(
                mExtraTextViews[i], new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
                                            LayoutParams.WRAP_CONTENT));
    }
}
 
源代码8 项目: geopaparazzi   文件: NoEditableLayerToolGroup.java
public void initUI() {

        LinearLayout parent = EditManager.INSTANCE.getToolsLayout();
        Context context = parent.getContext();
//        IEditableLayer editLayer = EditManager.INSTANCE.getEditLayer();
        int padding = 2;

        selectAllButton = new ImageButton(context);
        selectAllButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
        selectAllButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_select_all_24dp));
        selectAllButton.setPadding(0, padding, 0, padding);
        selectAllButton.setOnClickListener(this);
        selectAllButton.setOnTouchListener(this);
        parent.addView(selectAllButton);
    }
 
源代码9 项目: AndroidAPS   文件: StaticLabel.java
@Override
    public void addToLayout(LinearLayout root) {
        // text view pre element
        int px = MainApp.dpToPx(10);
        TextView textView = new TextView(root.getContext());
        textView.setText(label);
//       textViewPre.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,                ViewGroup.LayoutParams.WRAP_CONTENT));
        textView.setPadding(px, px, px, px);
        textView.setTypeface(textView.getTypeface(), Typeface.BOLD);
        textView.setBackgroundColor(MainApp.gc(R.color.mdtp_line_dark));
        // add element to layout
        root.addView(textView);
    }
 
源代码10 项目: AndroidAPS   文件: InputInsulin.java
@Override
public void addToLayout(LinearLayout root) {
    NumberPicker numberPicker = new NumberPicker(root.getContext(), null);
    numberPicker.setParams(0d, -20d, 20d, 0.1, new DecimalFormat("0.0"), true, null, textWatcher);
    numberPicker.setValue(value);
    numberPicker.setOnValueChangedListener(value -> this.value = value);
    root.addView(numberPicker);
}
 
源代码11 项目: AndroidAPS   文件: SWButton.java
@Override
public void generateDialog(LinearLayout layout) {
    Context context = layout.getContext();

    button = new Button(context);
    button.setText(buttonText);
    button.setOnClickListener((v) -> {
        if (buttonRunnable != null)
            buttonRunnable.run();
    });
    processVisibility();
    layout.addView(button);
    super.generateDialog(layout);
}
 
源代码12 项目: AndroidAPS   文件: SWHtmlLink.java
@Override
public void generateDialog(LinearLayout layout) {
    Context context = layout.getContext();

    l = new TextView(context);
    l.setId(View.generateViewId());
    l.setAutoLinkMask(Linkify.ALL);
    if(textLabel != null)
        l.setText(textLabel);
    else
        l.setText(label);
    layout.addView(l);

}
 
源代码13 项目: geopaparazzi   文件: PolygonOnSelectionToolGroup.java
public void initUI() {
        LinearLayout parent = EditManager.INSTANCE.getToolsLayout();
        parent.removeAllViews();

        Context context = parent.getContext();
        IEditableLayer editLayer = EditManager.INSTANCE.getEditLayer();
        int padding = 2;

        if (editLayer != null) {
            deleteFeatureButton = new ImageButton(context);
            deleteFeatureButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                    LayoutParams.WRAP_CONTENT));
            deleteFeatureButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_delete_feature_24dp));
            deleteFeatureButton.setPadding(0, padding, 0, padding);
            deleteFeatureButton.setOnTouchListener(this);
            deleteFeatureButton.setOnClickListener(this);
            parent.addView(deleteFeatureButton);

//            copyFeatureButton = new ImageButton(context);
//            copyFeatureButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
//                    LayoutParams.WRAP_CONTENT));
//            copyFeatureButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_copy_geoms_24dp));
//            copyFeatureButton.setPadding(0, padding, 0, padding);
//            copyFeatureButton.setOnTouchListener(this);
//            copyFeatureButton.setOnClickListener(this);
//            parent.addView(copyFeatureButton);

            editAttributesButton = new ImageButton(context);
            editAttributesButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                    LayoutParams.WRAP_CONTENT));
            editAttributesButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_view_attributes_24dp));
            editAttributesButton.setPadding(0, padding, 0, padding);
            editAttributesButton.setOnTouchListener(this);
            editAttributesButton.setOnClickListener(this);
            parent.addView(editAttributesButton);

            undoButton = new ImageButton(context);
            undoButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
            undoButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_undo_24dp));
            undoButton.setPadding(0, padding, 0, padding);
            undoButton.setOnTouchListener(this);
            undoButton.setOnClickListener(this);
            parent.addView(undoButton);

            commitButton = new ImageButton(context);
            commitButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
            commitButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_commit_24dp));
            commitButton.setPadding(0, padding, 0, padding);
            commitButton.setOnTouchListener(this);
            commitButton.setOnClickListener(this);
            parent.addView(commitButton);
            commitButton.setVisibility(View.GONE);
        }
    }
 
源代码14 项目: geopaparazzi   文件: PolygonMainEditingToolGroup.java
public void initUI() {

        LinearLayout parent = EditManager.INSTANCE.getToolsLayout();
        Context context = parent.getContext();
        IEditableLayer editLayer = EditManager.INSTANCE.getEditLayer();
        int padding = 2;

        if (editLayer != null) {
            cutButton = new ImageButton(context);
            cutButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
            cutButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_cut_24dp));
            cutButton.setPadding(0, padding, 0, padding);
            cutButton.setOnClickListener(this);
            cutButton.setOnTouchListener(this);
            parent.addView(cutButton);

            extendButton = new ImageButton(context);
            extendButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
            extendButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_extend_24dp));
            extendButton.setPadding(0, padding, 0, padding);
            extendButton.setOnClickListener(this);
            extendButton.setOnTouchListener(this);
            parent.addView(extendButton);

            createFeatureButton = new ImageButton(context);
            createFeatureButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                    LayoutParams.WRAP_CONTENT));
            createFeatureButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_create_polygon_24dp));
            createFeatureButton.setPadding(0, padding, 0, padding);
            createFeatureButton.setOnClickListener(this);
            createFeatureButton.setOnTouchListener(this);
            parent.addView(createFeatureButton);

            selectEditableButton = new ImageButton(context);
            selectEditableButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                    LayoutParams.WRAP_CONTENT));
            selectEditableButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_select_editable_24dp));
            selectEditableButton.setPadding(0, padding, 0, padding);
            selectEditableButton.setOnClickListener(this);
            selectEditableButton.setOnTouchListener(this);
            parent.addView(selectEditableButton);
        }

        selectAllButton = new ImageButton(context);
        selectAllButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
        Tool activeTool = EditManager.INSTANCE.getActiveTool();
        if (activeTool instanceof InfoTool) {
            selectAllButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_select_all_active_24dp));
        } else {
            selectAllButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_select_all_24dp));
        }
        selectAllButton.setPadding(0, padding, 0, padding);
        selectAllButton.setOnClickListener(this);
        selectAllButton.setOnTouchListener(this);
        parent.addView(selectAllButton);

        if (editLayer != null) {
            undoButton = new ImageButton(context);
            undoButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
            undoButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_undo_24dp));
            undoButton.setPadding(0, padding, 0, padding);
            undoButton.setOnTouchListener(this);
            undoButton.setOnClickListener(this);
            parent.addView(undoButton);
            undoButton.setVisibility(View.GONE);

            commitButton = new ImageButton(context);
            commitButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
            commitButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_commit_24dp));
            commitButton.setPadding(0, padding, 0, padding);
            commitButton.setOnTouchListener(this);
            commitButton.setOnClickListener(this);
            parent.addView(commitButton);
            commitButton.setVisibility(View.GONE);
        }
    }
 
源代码15 项目: AndroidAPS   文件: LabelWithElement.java
@Override
public void addToLayout(LinearLayout root) {
    // container layout
    LinearLayout layout = new LinearLayout(root.getContext());
    layout.setOrientation(LinearLayout.HORIZONTAL);
    layout.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));

    // text view pre element
    int px = MainApp.dpToPx(10);
    TextView textViewPre = new TextView(root.getContext());
    textViewPre.setText(textPre);
    textViewPre.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));
    //textViewPre.setWidth(MainApp.dpToPx(120));
    textViewPre.setPadding(px, px, px, px);
    textViewPre.setTypeface(textViewPre.getTypeface(), Typeface.BOLD);
    layout.addView(textViewPre);

    TextView spacer = new TextView(root.getContext());
    spacer.setLayoutParams(new TableLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, 1f));
    layout.addView(spacer);

    // add element to layout
    element.addToLayout(layout);

    // text view post element
    if (textPost != null) {
        px = MainApp.dpToPx(5);
        TextView textViewPost = new TextView(root.getContext());
        textViewPost.setText(textPost);
        textViewPost.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
                ViewGroup.LayoutParams.WRAP_CONTENT));
        //textViewPost.setWidth(MainApp.dpToPx(45));
        textViewPost.setPadding(px, px, px, px);
        textViewPost.setTypeface(textViewPost.getTypeface(), Typeface.BOLD);
        layout.addView(textViewPost);
    }

    // add layout to root layout
    root.addView(layout);
}
 
源代码16 项目: Simple-Brick-Games   文件: Main.java
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    createSoundPool();

    mLinearLayoutBackground = (LinearLayout) findViewById(R.id.linearLayoutBackground); //the whole display
    l1 = (LinearLayout) findViewById(R.id.LinearLayout1);
    linearLayoutMenuButtons = (LinearLayout) findViewById(R.id.linearLayoutMenuButtons);
    linearLayoutGameField = (LinearLayout) findViewById(R.id.linearLayoutGameField);
    linearLayoutTexts = (LinearLayout) findViewById(R.id.linearLayoutTexts);
    linearLayoutGameExtra = (LinearLayout) findViewById(R.id.linearLayoutGameExtra);
    layoutButtons1 = (LinearLayout) findViewById(R.id.layoutButtons1);
    layoutButtons2 = (FrameLayout) findViewById(R.id.layoutButtons2);
    vibration = (Vibrator) getSystemService(VIBRATOR_SERVICE);
    mToolbar = (Toolbar) findViewById(R.id.toolbar);

    gameView1 = new GameView1(linearLayoutGameField.getContext());
    gameView2 = new GameView2(linearLayoutGameExtra.getContext());

    mButton[0] = (ImageView) findViewById(R.id.button_up);
    mButton[1] = (ImageView) findViewById(R.id.button_down);
    mButton[2] = (ImageView) findViewById(R.id.button_left);
    mButton[3] = (ImageView) findViewById(R.id.button_right);
    mButton[4] = (ImageView) findViewById(R.id.button_action);
    mButton[5] = (ImageView) findViewById(R.id.button_reset);
    mButton[6] = (ImageView) findViewById(R.id.button_pause);
    mButton[7] = (ImageView) findViewById(R.id.button_close);

    mText[0] = (TextView) findViewById(R.id.text_highscore);
    mText[1] = (TextView) findViewById(R.id.text_score);
    mText[2] = (TextView) findViewById(R.id.text_level);
    mText[3] = (TextView) findViewById(R.id.text_speed);
    mText[4] = (TextView) findViewById(R.id.text_pause);

    soundList[0] = sp.load(this, R.raw.beep, 1);
    soundList[1] = sp.load(this, R.raw.boing, 1);
    soundList[2] = sp.load(this, R.raw.explosion, 1);
    soundList[3] = sp.load(this, R.raw.boop, 1);
    soundList[4] = sp.load(this, R.raw.crunch, 1);
    soundList[5] = sp.load(this, R.raw.next, 1);
    soundList[6] = sp.load(this, R.raw.gameover, 1);
    soundList[7] = sp.load(this, R.raw.shoot, 1);

    mainActivity = this;
    setSupportActionBar(mToolbar);

    /* Load saved SharedData */
    savedData = PreferenceManager.getDefaultSharedPreferences(this);
    edit = savedData.edit();
    for (int i = 1; i <= NUMBER_OF_GAMES; i++)
        highScores[i] = savedData.getInt("HighScore" + Integer.toString(i), 0);
    look = savedData.getInt(getString(R.string.prefKeyTextures), 2);
    menu.load();

    Game.reset();

    for (int i=0;i<5;i++) {
        mButton[i].setOnTouchListener(this);
    }

    setBackgroundColor();
    changeButtonColor();

    linearLayoutGameField.addView(gameView1);
    linearLayoutGameExtra.addView(gameView2);

    /* set up the layouts (the layouts will be rearranged to fit the calculated field dimensions)*/
    mLinearLayoutBackground.post(new Runnable() {
        @Override
        public void run() {
            if (getResources().getConfiguration().orientation==Configuration.ORIENTATION_PORTRAIT) {
                setUpDimensions();
            } else {
                setUpDimensionsLandscape();
            }
        }
    });

    buttonKeyCodes[0] = savedData.getInt("buttonUp",KeyEvent.KEYCODE_W);
    buttonKeyCodes[1] = savedData.getInt("buttonDown",KeyEvent.KEYCODE_S);
    buttonKeyCodes[2] = savedData.getInt("buttonLeft",KeyEvent.KEYCODE_A);
    buttonKeyCodes[3] = savedData.getInt("buttonRight",KeyEvent.KEYCODE_D);
    buttonKeyCodes[4] = savedData.getInt("buttonAction",KeyEvent.KEYCODE_L);
    buttonKeyCodes[5] = savedData.getInt("buttonClose",KeyEvent.KEYCODE_X);
    buttonKeyCodes[6] = savedData.getInt("buttonReset",KeyEvent.KEYCODE_R);
    buttonKeyCodes[7] = savedData.getInt("buttonPause",KeyEvent.KEYCODE_P);
}
 
public PathAdapter(LinearLayout linearLayout)
{
    mLinearLayout = linearLayout;
    mContext = linearLayout.getContext();
}
 
源代码18 项目: AndroidAPS   文件: Trigger.java
public void generateDialog(LinearLayout root, FragmentManager fragmentManager) {
    TextView title = new TextView(root.getContext());
    title.setText(friendlyName());
    root.addView(title);
}
 
源代码19 项目: geopaparazzi   文件: PointCreateFeatureToolGroup.java
public void initUI() {
    LinearLayout parent = EditManager.INSTANCE.getToolsLayout();
    parent.removeAllViews();

    Context context = parent.getContext();
    IEditableLayer editLayer = EditManager.INSTANCE.getEditLayer();
    int padding = 2;

    if (editLayer != null) {
        gpsStreamButton = new ImageButton(context);
        gpsStreamButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
        gpsStreamButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_add_point_gps_off_24dp));
        gpsStreamButton.setPadding(0, padding, 0, padding);
        gpsStreamButton.setOnTouchListener(this);
        gpsStreamButton.setOnLongClickListener(this);
        gpsStreamButton.setOnClickListener(this);
        parent.addView(gpsStreamButton);

        addVertexButton = new ImageButton(context);
        addVertexButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
        addVertexButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_add_point_center_24dp));
        addVertexButton.setPadding(0, padding, 0, padding);
        addVertexButton.setOnTouchListener(this);
        addVertexButton.setOnClickListener(this);
        parent.addView(addVertexButton);

        addVertexByTapButton = new ImageButton(context);
        addVertexByTapButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT));
        addVertexByTapButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_add_point_tap_off_24dp));
        addVertexByTapButton.setPadding(0, padding, 0, padding);
        addVertexByTapButton.setOnTouchListener(this);
        addVertexByTapButton.setOnClickListener(this);
        parent.addView(addVertexByTapButton);

        undoButton = new ImageButton(context);
        undoButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
        undoButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_undo_24dp));
        undoButton.setPadding(0, padding, 0, padding);
        undoButton.setOnTouchListener(this);
        undoButton.setOnClickListener(this);
        parent.addView(undoButton);

        commitButton = new ImageButton(context);
        commitButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
        commitButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_commit_24dp));
        commitButton.setPadding(0, padding, 0, padding);
        commitButton.setOnTouchListener(this);
        commitButton.setOnClickListener(this);
        commitButton.setVisibility(View.GONE);
        parent.addView(commitButton);
    }
}
 
源代码20 项目: AndroidAPS   文件: SWPlugin.java
@Override
public void generateDialog(LinearLayout layout) {

    Context context = layout.getContext();
    radioGroup = new RadioGroup(context);
    radioGroup.clearCheck();

    ArrayList<PluginBase> pluginsInCategory = MainApp.getSpecificPluginsList(pType);

    radioGroup.setOrientation(LinearLayout.VERTICAL);
    radioGroup.setVisibility(View.VISIBLE);

    TextView pdesc = new TextView(context);
    pdesc.setText(pluginDescription);
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    params.setMargins(0, 0, 0, 40);
    pdesc.setLayoutParams(params);
    layout.addView(pdesc);

    for (int i = 0; i < pluginsInCategory.size(); i++) {
        RadioButton rdbtn = new RadioButton(context);
        PluginBase p = pluginsInCategory.get(i);
        rdbtn.setId(View.generateViewId());
        rdbtn.setText(p.getName());
        if (p.isEnabled(pType))
            rdbtn.setChecked(true);
        rdbtn.setTag(p);
        radioGroup.addView(rdbtn);
        params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        params.setMargins(80, 0, 0, 0);
        TextView desc = new TextView(context);
        desc.setText(p.getDescription());
        desc.setLayoutParams(params);
        radioGroup.addView(desc);
    }

    radioGroup.setOnCheckedChangeListener((group, checkedId) -> {
        RadioButton rb = group.findViewById(checkedId);
        PluginBase plugin = (PluginBase) rb.getTag();
        plugin.setPluginEnabled(pType, rb.isChecked());
        plugin.setFragmentVisible(pType, rb.isChecked() && makeVisible);
        ConfigBuilderPlugin.getPlugin().processOnEnabledCategoryChanged(plugin, pType);
        ConfigBuilderPlugin.getPlugin().storeSettings("SetupWizard");
        RxBus.INSTANCE.send(new EventConfigBuilderChange());
        RxBus.INSTANCE.send(new EventSWUpdate(false));
    });
    layout.addView(radioGroup);
    super.generateDialog(layout);
}