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

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

源代码1 项目: Ruisi   文件: MyBottomTab.java
private View getSingleTab(int position) {
    LinearLayout view = new LinearLayout(getContext());
    view.setClickable(true);
    view.setGravity(Gravity.CENTER);
    view.setBackgroundResource(CLICK_BG_RES);
    view.setOrientation(LinearLayout.VERTICAL);

    //图标
    ImageView iconView = new ImageView(getContext());
    //三个参数的构造可以设置权重
    iconView.setLayoutParams(new LayoutParams(SIZE_ICON, SIZE_ICON));
    iconView.setImageResource(iconsUnselect[position]);
    iconView.setColorFilter(COLOR_UNSELECT);
    //标题
    TextView textView = new TextView(getContext());
    textView.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
    textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12);
    textView.setTextAlignment(TEXT_ALIGNMENT_CENTER);
    textView.setGravity(Gravity.CENTER);
    textView.setTextColor(COLOR_UNSELECT);
    textView.setText(tabNames[position]);
    view.addView(iconView);
    view.addView(textView);
    // 返回布局视图
    return view;
}
 
源代码2 项目: SettingView   文件: SwitchItemView.java
private void init(Context context) {
	mInflater = LayoutInflater.from(context);
	mItemView = mInflater.inflate(R.layout.setting_view_switch_item, null);
	addView(mItemView);

	mTitle = (TextView) mItemView.findViewById(R.id.setting_view_switch_item_title);
	mDrawable = (ImageView) mItemView.findViewById(R.id.setting_view_switch_item_icon);
	mSwitch = (SwitchButton) mItemView.findViewById(R.id.setting_view_switch_item_switch);
	mItemViewContainer = (LinearLayout) mItemView.findViewById(R.id.setting_view_switch_item_container);

	mItemViewContainer.setClickable(false);

	mSwitch.setOnCheckedChangeListener(new OnCheckedChangeListener() {

		@Override
		public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
			// TODO Auto-generated method stub
			if (null != mChangedListener) {
				mChangedListener.onSwitchItemChanged(isChecked);
			}
		}
	});
}
 
源代码3 项目: BigApp_Discuz_Android   文件: AsyncTaskExtend.java
@Override
protected void onPostExecute(Object result) {

    ZogUtils.printLog(AsyncTaskExtend.class, "onPostExecute");

    for (Button b : btns) {
        b.setClickable(true);
    }
    for (LinearLayout ll : linearLayouts) {
        ll.setClickable(true);
    }
}
 
源代码4 项目: ZhiHu-TopAnswer   文件: AnswersActivity.java
private void initStateView() {
    LinearLayout error  = (LinearLayout) mStateView.findViewById(R.id.error_root_layout);
    error.setClickable(true);
    error.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            initData(true);
        }
    });
}
 
源代码5 项目: ZhiHu-TopAnswer   文件: AnswerDetailActivity.java
private void initStateView() {
    LinearLayout error  = (LinearLayout) mStateView.findViewById(R.id.error_root_layout);
    error.setClickable(true);
    error.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            initData(true);
        }
    });
}
 
源代码6 项目: NightSight   文件: Darkness.java
private void createView() {

        Log.i(TAG, "View created");
        //  myView = new LinearLayout(new ContextThemeWrapper(getApplicationContext(), R.style.Theme_Transparent), null, 0);
        myView = new LinearLayout(getApplicationContext());
        wm = (WindowManager) getApplicationContext().getSystemService(Context.WINDOW_SERVICE);
        wmParams = new WindowManager.LayoutParams(WindowManager.LayoutParams.MATCH_PARENT,
                WindowManager.LayoutParams.MATCH_PARENT,
                WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
                WindowManager.LayoutParams.FLAG_FULLSCREEN,
                PixelFormat.TRANSLUCENT);


        /**
         *
         * Window type: phone.  These are non-application windows providing
         * user interaction with the phone (in particular incoming calls).
         * These windows are normally placed above all applications, but behind
         * the status bar.
         */
        wmParams.flags = WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH | WindowManager.LayoutParams.FLAG_FULLSCREEN;
        wmParams.gravity = Gravity.START | Gravity.TOP;
        wmParams.x = 0;
        wmParams.y = 0;
  myView.setBackgroundColor(ContextCompat.
                getColor(this, sharedPreferences.getInt(SharedPrefs.KEY_COLOR_ID, R.color.black)));


        wmParams.alpha = (1.0f - ((BRIGHTNESS + 55) / (float) 255));
        myView.setClickable(false);
        wm.addView(myView, wmParams);

    }
 
源代码7 项目: RxJavaApp   文件: MainActivity.java
private void initNavigationView() {
    drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    toggle = new ActionBarDrawerToggle(
            this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();

    navigationView = (NavigationView) findViewById(R.id.nav_view);

    mHeadView = (LinearLayout) navigationView.getHeaderView(0);
    mNavRecyclerView = (RecyclerView) navigationView.getHeaderView(0).findViewById(R.id.index_nav_recycler);
    mHeadView.setClickable(true);
    mHeadView.setOnClickListener(this);

}
 
private View getTitleView(MainActivity activity, Account account, DirectMessage message) {
    View view = activity.getLayoutInflater().inflate(R.layout.dialog_status_detail, null);
    View messageHeader = view.findViewById(R.id.layout_status_header);
    MessageViewModel statusViewModel = new MessageViewModel(message, account);
    messageHeader = statusViewModel.getView(activity, activity.getLayoutInflater(), messageHeader);
    messageHeader.setClickable(false);
    int background = ((ColorDrawable) messageHeader.getBackground()).getColor();
    view.setBackgroundColor(background);
    ImageButton reply = (ImageButton) view.findViewById(R.id.button_status_detail_reply);
    reply.setOnClickListener(this);
    ImageButton delete = (ImageButton) view.findViewById(R.id.button_status_detail_delete);
    delete.setVisibility(isDeletable(account, message) ? View.VISIBLE : View.GONE);
    delete.setOnClickListener(this);
    ImageButton menuButton = (ImageButton) view.findViewById(R.id.button_status_detail_menu);
    menuButton.setOnClickListener(this);
    LinearLayout commandsLayout = (LinearLayout) view.findViewById(R.id.linearlayout_status_detail_menu);
    commandsLayout.setClickable(true);
    // commands
    ArrayList<Command> commands = getCommands(activity, message, account);
    Command.filter(commands);
    for (final Command command : commands) {
        View commandView = command.getView(activity, activity.getLayoutInflater(), null);
        commandView.setBackgroundColor(getResources().getColor(R.color.transparent));
        commandView.setOnClickListener(new ListItemClickListener(activity, new Runnable() {
            @Override
            public void run() {
                command.execute();
                dismiss();
            }
        }));
        commandsLayout.addView(commandView);
    }
    // status only parts
    view.findViewById(R.id.button_status_detail_retweet).setVisibility(View.GONE);
    view.findViewById(R.id.button_status_detail_favorite).setVisibility(View.GONE);
    view.findViewById(R.id.image_status_detail_fav_count).setVisibility(View.GONE);
    view.findViewById(R.id.image_status_detail_rt_count).setVisibility(View.GONE);
    return view;
}
 
源代码9 项目: open-rmbt   文件: RMBTMainActivity.java
public void setOverlayVisibility(boolean isVisible) {
    final LinearLayout overlay = (LinearLayout) findViewById(R.id.overlay);

    if (isVisible) {
    	overlay.setVisibility(View.VISIBLE);
    	overlay.setClickable(true);
    	overlay.bringToFront();
    }
    else {
    	overlay.setVisibility(View.GONE);
    }
}
 
源代码10 项目: SegmentedButton   文件: SegmentedButtonGroup.java
private void init(Context context, @Nullable AttributeSet attrs)
{
    // Create and set outline provider for the segmented button group
    // This is used to provide an outline for the layout because it may have rounded corners
    // The primary benefit to using this is that shadows will follow the contour of the outline rather than the
    // rectangular bounds
    if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP)
        setOutlineProvider(new OutlineProvider());

    buttons = new ArrayList<>();

    // This FrameLayout is used in order to stack the button layout, border view & divider layout on top of each
    // other rather than horizontally or vertically like this SegmentedButtonGroup would do(it inherits from
    // LinearLayout)
    //
    // Why have a LinearLayout(SegmentedButtonGroup) with only one child of FrameLayout?
    // Although it seems redundant, it is so that SegmentedButton children can be specified in the layout XML of
    // the SegmentedButtonGroup with layout weight parameters. If SegmentedButtonGroup subclassed FrameLayout,
    // the layout weight would be ignored even though the SegmentedButtons are passed to buttonLayout.
    FrameLayout container = new FrameLayout(getContext());
    // Call super addView so that we do not trigger an Exception since only SegmentedButton instances can be
    // added to this view
    super.addView(container, -1, new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT,
        LayoutParams.MATCH_PARENT));

    // Layout that contains all SegmentedButton's
    buttonLayout = new LinearLayout(getContext());
    buttonLayout.setLayoutParams(new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT,
        LayoutParams.WRAP_CONTENT));
    buttonLayout.setOrientation(LinearLayout.HORIZONTAL);
    container.addView(buttonLayout);

    // Create border view
    // This is essentially a dummy view that is drawn on top of the buttonLayout so that the border appears on
    // top of them
    borderView = new EmptyView(context);
    borderView.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
        ViewGroup.LayoutParams.MATCH_PARENT));
    container.addView(borderView);

    // Create layout that contains dividers for each button
    // This layout will essentially mirror the number of elements, size, weight of each element with the only
    // difference being that the elements will be transparent and that a divider will be placed between each one
    //
    // The benefit to placing the dividers in this dummy layout is so that the dividers appear on top of the
    // buttons without taking up additional width, which is what happens if the dividers are added to the
    // buttonLayout
    dividerLayout = new LinearLayout(getContext());
    dividerLayout.setLayoutParams(new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT,
        LayoutParams.MATCH_PARENT));
    dividerLayout.setOrientation(LinearLayout.HORIZONTAL);
    dividerLayout.setClickable(false);
    dividerLayout.setFocusable(false);
    container.addView(dividerLayout);

    // Retrieve custom attributes
    getAttributes(context, attrs);
}
 
源代码11 项目: onpc   文件: DeviceFragment.java
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
    initializeFragment(inflater, container, R.layout.device_fragment);

    // Friendly name
    {
        friendlyName = rootView.findViewById(R.id.device_edit_friendly_name);
        final AppCompatImageButton b = rootView.findViewById(R.id.device_change_friendly_name);
        prepareButtonListeners(b, null, () ->
        {
            if (activity.isConnected())
            {
                activity.getStateManager().sendMessage(
                        new FriendlyNameMsg(friendlyName.getText().toString()));
                // #119: Improve clearing focus for friendly name edit field
                friendlyName.clearFocus();
            }
        });
        setButtonEnabled(b, true);

        // #119: Improve clearing focus for friendly name edit field
        // OnClick for background layout: clear focus for friendly name text field
        {
            LinearLayout l = rootView.findViewById(R.id.device_background_layout);
            l.setClickable(true);
            l.setEnabled(true);
            l.setOnClickListener((v) -> friendlyName.clearFocus());
        }
    }

    prepareImageButton(R.id.btn_firmware_update, new FirmwareUpdateMsg(FirmwareUpdateMsg.Status.NET));
    prepareImageButton(R.id.device_dimmer_level_toggle, new DimmerLevelMsg(DimmerLevelMsg.Level.TOGGLE));
    prepareImageButton(R.id.device_digital_filter_toggle, new DigitalFilterMsg(DigitalFilterMsg.Filter.TOGGLE));
    prepareImageButton(R.id.music_optimizer_toggle, new MusicOptimizerMsg(MusicOptimizerMsg.Status.TOGGLE));
    prepareImageButton(R.id.device_auto_power_toggle, new AutoPowerMsg(AutoPowerMsg.Status.TOGGLE));
    prepareImageButton(R.id.hdmi_cec_toggle, new HdmiCecMsg(HdmiCecMsg.Status.TOGGLE));
    prepareImageButton(R.id.phase_matching_bass_toggle, new PhaseMatchingBassMsg(PhaseMatchingBassMsg.Status.TOGGLE));
    prepareImageButton(R.id.sleep_time_toggle, null);
    prepareImageButton(R.id.speaker_ab_command_toggle, null);
    prepareImageButton(R.id.google_cast_analytics_toggle, null);

    updateContent();
    return rootView;
}
 
源代码12 项目: microbit   文件: ProjectAdapter.java
@Override
public View getView(int position, View convertView, ViewGroup parent) {

    Project project = mProjects.get(position);
    if(convertView == null) {
        LayoutInflater inflater = LayoutInflater.from(MBApp.getApp());
        convertView = inflater.inflate(R.layout.project_items, null);
    }

    Button appNameButton = (Button) convertView.findViewById(R.id.appNameButton);
    appNameButton.setTypeface(MBApp.getApp().getRobotoTypeface());

    ExtendedEditText appNameEdit = (ExtendedEditText) convertView.findViewById(R.id.appNameEdit);
    appNameEdit.setTypeface(MBApp.getApp().getRobotoTypeface());

    LinearLayout actionBarLayout = (LinearLayout) convertView.findViewById(R.id.actionBarForProgram);
    if(actionBarLayout != null) {
        if(project.actionBarExpanded) {
            actionBarLayout.setVisibility(View.VISIBLE);
            appNameButton.setCompoundDrawablesWithIntrinsicBounds(null, null, ContextCompat.getDrawable(MBApp.getApp()
                    , R.drawable.ic_arrow_down), null);
        } else {
            actionBarLayout.setVisibility(View.GONE);
            appNameButton.setCompoundDrawablesWithIntrinsicBounds(null, null, ContextCompat.getDrawable(MBApp.getApp()
                    , R.drawable.ic_arrow_left), null);
        }
    }

    appNameButton.setText(project.name);
    appNameButton.setTag(R.id.positionId, position);
    appNameButton.setTag(R.id.textEdit, appNameEdit);
    appNameButton.setOnClickListener(appNameClickListener);
    appNameButton.setOnLongClickListener(appNameLongClickListener);

    appNameEdit.setTag(R.id.positionId, position);
    appNameEdit.setTag(R.id.editbutton, appNameButton);
    appNameEdit.setOnEditorActionListener(editorOnActionListener);
    appNameEdit.setFilters(new InputFilter[]{renameFilter});

    if(project.inEditMode) {
        appNameEdit.setVisibility(View.VISIBLE);

        appNameEdit.setText(project.name);
        appNameEdit.setSelection(project.name.length());
        appNameEdit.requestFocus();
        appNameButton.setVisibility(View.INVISIBLE);

    } else {
        appNameEdit.setVisibility(View.INVISIBLE);
        appNameButton.setVisibility(View.VISIBLE);
        //dismissKeyBoard(appNameEdit, false);
    }

    //appNameEdit.setOnClickListener(appNameClickListener);

    TextView flashBtnText = (TextView) convertView.findViewById(R.id.project_item_text);
    flashBtnText.setTypeface(MBApp.getApp().getRobotoTypeface());
    LinearLayout sendBtnLayout = (LinearLayout) convertView.findViewById(R.id.sendBtn);
    sendBtnLayout.setTag(position);
    sendBtnLayout.setOnClickListener(sendBtnClickListener);

    ImageButton deleteBtn = (ImageButton) convertView.findViewById(R.id.deleteBtn);
    deleteBtn.setTag(position);
    deleteBtn.setOnClickListener(deleteBtnClickListener);
    deleteBtn.setEnabled(true);


    Drawable myIcon;
    if(project.runStatus) {
        flashBtnText.setText("");
        myIcon = convertView.getResources().getDrawable(R.drawable.green_btn);
    } else {
        flashBtnText.setText(R.string.flash);
        myIcon = convertView.getResources().getDrawable(R.drawable.blue_btn);
    }
    sendBtnLayout.setBackground(myIcon);

    sendBtnLayout.setClickable(true);
    return convertView;
}
 
源代码13 项目: iGap-Android   文件: ViewMaker.java
static View getViewReplay() {

        LinearLayout cslr_replay_layout = new LinearLayout(context);
        cslr_replay_layout.setId(R.id.cslr_replay_layout);
        cslr_replay_layout.setBackgroundColor(context.getResources().getColor(R.color.messageBox_replyBoxBackgroundSend));
        cslr_replay_layout.setClickable(true);
        cslr_replay_layout.setOrientation(HORIZONTAL);
        cslr_replay_layout.setPadding(i_Dp(R.dimen.messageContainerPaddingLeftRight), i_Dp(R.dimen.messageContainerPaddingLeftRight), i_Dp(R.dimen.messageContainerPaddingLeftRight), i_Dp(R.dimen.messageContainerPaddingLeftRight));
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
            cslr_replay_layout.setTextDirection(View.TEXT_DIRECTION_LOCALE);
        }

        setLayoutDirection(cslr_replay_layout, View.LAYOUT_DIRECTION_LOCALE);

        LinearLayout.LayoutParams layout_468 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        cslr_replay_layout.setLayoutParams(layout_468);

        View verticalLine = new View(context);
        verticalLine.setId(R.id.verticalLine);
        verticalLine.setBackgroundColor(Color.parseColor("#f7ab07"));
        LinearLayout.LayoutParams layout_81 = new LinearLayout.LayoutParams(dpToPixel(3), ViewGroup.LayoutParams.MATCH_PARENT);

        if (HelperCalander.isPersianUnicode) {
            layout_81.leftMargin = i_Dp(dp8);
        } else {
            layout_81.rightMargin = i_Dp(dp8);
        }

        verticalLine.setLayoutParams(layout_81);
        cslr_replay_layout.addView(verticalLine);

        ImageView chslr_imv_replay_pic = new ImageView(context);
        chslr_imv_replay_pic.setId(R.id.chslr_imv_replay_pic);
        chslr_imv_replay_pic.setAdjustViewBounds(true);

        LinearLayout.LayoutParams layout_760 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, i_Dp(R.dimen.dp40));

        if (HelperCalander.isPersianUnicode) {
            layout_760.leftMargin = i_Dp(dp8);
        } else {
            layout_760.rightMargin = i_Dp(dp8);
        }

        chslr_imv_replay_pic.setLayoutParams(layout_760);
        cslr_replay_layout.addView(chslr_imv_replay_pic);

        LinearLayout linearLayout_376 = new LinearLayout(context);
        linearLayout_376.setGravity(LEFT);

        linearLayout_376.setOrientation(VERTICAL);
        LinearLayout.LayoutParams layout_847 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, 1);
        linearLayout_376.setLayoutParams(layout_847);

        EmojiTextViewE chslr_txt_replay_from = new EmojiTextViewE(context);
        chslr_txt_replay_from.setId(R.id.chslr_txt_replay_from);
        chslr_txt_replay_from.setSingleLine(true);
        chslr_txt_replay_from.setPadding(0, 0, 0, 0);

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
            chslr_txt_replay_from.setTextDirection(View.TEXT_DIRECTION_FIRST_STRONG);
        }

        chslr_txt_replay_from.setText("");

        chslr_txt_replay_from.setTextColor(context.getResources().getColor(R.color.colorOldBlack));
        chslr_txt_replay_from.setTextAppearance(context, R.style.ChatMessages_EmojiTextView);
        setTextSize(chslr_txt_replay_from, R.dimen.dp12);

        chslr_txt_replay_from.setTypeface(G.typeface_IRANSansMobile_Bold);
        LinearLayout.LayoutParams layout_55 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        chslr_txt_replay_from.setLayoutParams(layout_55);
        linearLayout_376.addView(chslr_txt_replay_from);

        EmojiTextViewE chslr_txt_replay_message = new EmojiTextViewE(context);
        chslr_txt_replay_message.setId(R.id.chslr_txt_replay_message);
        chslr_txt_replay_message.setEllipsize(TextUtils.TruncateAt.END);
        chslr_txt_replay_message.setSingleLine(true);
        chslr_txt_replay_message.setPadding(0, 0, 0, 0);
        chslr_txt_replay_message.setText("");

        chslr_txt_replay_message.setTextColor(Color.WHITE);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
            chslr_txt_replay_message.setTextDirection(View.TEXT_DIRECTION_FIRST_STRONG);
        }

        chslr_txt_replay_message.setTextAppearance(context, R.style.ChatMessages_EmojiTextView);
        setTextSize(chslr_txt_replay_message, R.dimen.dp12);
        LinearLayout.LayoutParams layout_641 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        chslr_txt_replay_message.setLayoutParams(layout_641);
        chslr_txt_replay_message.setTypeface(G.typeface_IRANSansMobile);
        linearLayout_376.addView(chslr_txt_replay_message);
        cslr_replay_layout.addView(linearLayout_376);

        return cslr_replay_layout;
    }
 
源代码14 项目: iGap-Android   文件: ViewMaker.java
static View getViewForward() {

        LinearLayout cslr_ll_forward = new LinearLayout(context);
        cslr_ll_forward.setId(R.id.cslr_ll_forward);
        cslr_ll_forward.setClickable(true);
        cslr_ll_forward.setOrientation(HORIZONTAL);
        cslr_ll_forward.setPadding(i_Dp(R.dimen.messageContainerPaddingLeftRight), i_Dp(messageContainerPadding), i_Dp(R.dimen.messageContainerPaddingLeftRight), i_Dp(messageContainerPadding));
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
            cslr_ll_forward.setTextDirection(View.TEXT_DIRECTION_LOCALE);
        }
        setLayoutDirection(cslr_ll_forward, View.LAYOUT_DIRECTION_LOCALE);

        LinearLayout.LayoutParams layout_687 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        cslr_ll_forward.setLayoutParams(layout_687);

        View View_997 = new View(context);
        View_997.setBackgroundColor(Color.parseColor(G.textBubble));
        LinearLayout.LayoutParams layout_547 = new LinearLayout.LayoutParams(dpToPixel(2), ViewGroup.LayoutParams.MATCH_PARENT);
        layout_547.rightMargin = dpToPixel(3);
        View_997.setLayoutParams(layout_547);
        cslr_ll_forward.addView(View_997);


        TextView cslr_txt_prefix_forward = new TextView(context);
        cslr_txt_prefix_forward.setId(R.id.cslr_txt_prefix_forward);
        cslr_txt_prefix_forward.setText(context.getResources().getString(R.string.forwarded_from));
        cslr_txt_prefix_forward.setTextColor(Color.parseColor(G.textBubble));
        setTextSize(cslr_txt_prefix_forward, R.dimen.dp12);
        cslr_txt_prefix_forward.setSingleLine(true);
        cslr_txt_prefix_forward.setTypeface(G.typeface_IRANSansMobile_Bold);
        LinearLayout.LayoutParams layout_992 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        layout_992.rightMargin = i_Dp(dp4);
        layout_992.leftMargin = i_Dp(R.dimen.dp6);
        cslr_txt_prefix_forward.setLayoutParams(layout_992);
        cslr_ll_forward.addView(cslr_txt_prefix_forward);

        TextView cslr_txt_forward_from = new TextView(context);
        cslr_txt_forward_from.setId(R.id.cslr_txt_forward_from);
        cslr_txt_forward_from.setMinimumWidth(i_Dp(R.dimen.dp100));
        cslr_txt_forward_from.setMaxWidth(i_Dp(R.dimen.dp140));
        cslr_txt_forward_from.setTextColor(Color.parseColor(G.textBubble));
        setTextSize(cslr_txt_forward_from, R.dimen.dp12);
        cslr_txt_forward_from.setSingleLine(true);
        cslr_txt_forward_from.setTypeface(G.typeface_IRANSansMobile_Bold);
        LinearLayout.LayoutParams layout_119 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        cslr_txt_forward_from.setLayoutParams(layout_119);
        cslr_ll_forward.addView(cslr_txt_forward_from);


        return cslr_ll_forward;
    }
 
源代码15 项目: SegmentedButton   文件: SegmentedButtonGroup.java
private void init(AttributeSet attrs) {
    getAttributes(attrs);
    setWillNotDraw(false);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        setOutlineProvider(new ButtonOutlineProvider());
    }

    setClickable(true);

    buttons = new ArrayList<>();

    FrameLayout container = new FrameLayout(getContext());
    container.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    addView(container);

    mainGroup = new LinearLayout(getContext());
    mainGroup.setLayoutParams(new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    mainGroup.setOrientation(LinearLayout.HORIZONTAL);
    container.addView(mainGroup);

    rippleContainer = new LinearLayout(getContext());
    rippleContainer.setLayoutParams(new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    rippleContainer.setOrientation(LinearLayout.HORIZONTAL);
    rippleContainer.setClickable(false);
    rippleContainer.setFocusable(false);
    rippleContainer.setPadding(borderSize, borderSize, borderSize, borderSize);
    container.addView(rippleContainer);

    dividerContainer = new LinearLayout(getContext());
    dividerContainer.setLayoutParams(new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    dividerContainer.setOrientation(LinearLayout.HORIZONTAL);
    dividerContainer.setClickable(false);
    dividerContainer.setFocusable(false);
    container.addView(dividerContainer);

    initInterpolations();
    setContainerAttrs();
    setDividerAttrs();

    rectF = new RectF();
    paint = new Paint(Paint.ANTI_ALIAS_FLAG);
}
 
源代码16 项目: SeeWeather   文件: SettingFragment.java
private void showIconDialog() {
    LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View dialogLayout = inflater.inflate(R.layout.dialog_icon, (ViewGroup) getActivity().findViewById(R.id.dialog_root));
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()).setView(dialogLayout);
    final AlertDialog alertDialog = builder.create();

    LinearLayout layoutTypeOne = (LinearLayout) dialogLayout.findViewById(R.id.layout_one);
    layoutTypeOne.setClickable(true);
    RadioButton radioTypeOne = (RadioButton) dialogLayout.findViewById(R.id.radio_one);
    LinearLayout layoutTypeTwo = (LinearLayout) dialogLayout.findViewById(R.id.layout_two);
    layoutTypeTwo.setClickable(true);
    RadioButton radioTypeTwo = (RadioButton) dialogLayout.findViewById(R.id.radio_two);
    TextView done = (TextView) dialogLayout.findViewById(R.id.done);

    radioTypeOne.setClickable(false);
    radioTypeTwo.setClickable(false);

    alertDialog.show();

    switch (mSharedPreferenceUtil.getIconType()) {
        case 0:
            radioTypeOne.setChecked(true);
            radioTypeTwo.setChecked(false);
            break;
        case 1:
            radioTypeOne.setChecked(false);
            radioTypeTwo.setChecked(true);
            break;
    }

    layoutTypeOne.setOnClickListener(v -> {
        radioTypeOne.setChecked(true);
        radioTypeTwo.setChecked(false);
    });

    layoutTypeTwo.setOnClickListener(v -> {
        radioTypeOne.setChecked(false);
        radioTypeTwo.setChecked(true);
    });

    done.setOnClickListener(v -> {
        mSharedPreferenceUtil.setIconType(radioTypeOne.isChecked() ? 0 : 1);
        String[] iconsText = getResources().getStringArray(R.array.icons);
        mChangeIcons.setSummary(radioTypeOne.isChecked() ? iconsText[0] :
            iconsText[1]);
        alertDialog.dismiss();
        Snackbar.make(getView(), "切换成功,重启应用生效",
            Snackbar.LENGTH_INDEFINITE).setAction("重启",
            v1 -> {
                Intent intent = new Intent(getActivity(), MainActivity.class);
                intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                getActivity().startActivity(intent);
                getActivity().finish();
                RxBus.getDefault().post(new ChangeCityEvent());
            }).show();
    });
}
 
源代码17 项目: Dashchan   文件: ThreadsAdapter.java
public ThreadsAdapter(Context context, String chanName, String boardName, UiManager uiManager) {
	this.context = context;
	this.chanName = chanName;
	this.boardName = boardName;
	this.uiManager = uiManager;
	hidePerformer = new HidePerformer();
	float density = ResourceUtils.obtainDensity(context);
	FrameLayout frameLayout = new FrameLayout(context);
	frameLayout.setPadding((int) (10f * density), (int) (6f * density), (int) (10f * density), 0);
	headerClickableView = new ClickableView(context);
	headerClickableView.setOnClickListener(this);
	frameLayout.addView(headerClickableView, FrameLayout.LayoutParams.MATCH_PARENT,
			FrameLayout.LayoutParams.MATCH_PARENT);
	LinearLayout linearLayout = new LinearLayout(context);
	linearLayout.setOrientation(LinearLayout.VERTICAL);
	frameLayout.addView(linearLayout, FrameLayout.LayoutParams.MATCH_PARENT,
			FrameLayout.LayoutParams.WRAP_CONTENT);
	linearLayout.setPadding((int) (10f * density), (int) (4f * density),
			(int) (10f * density), (int) (4f * density));
	LinearLayout innerLayout = new LinearLayout(context);
	innerLayout.setOrientation(LinearLayout.HORIZONTAL);
	linearLayout.addView(innerLayout, LinearLayout.LayoutParams.MATCH_PARENT,
			LinearLayout.LayoutParams.WRAP_CONTENT);
	LinearLayout topLayout = new LinearLayout(context);
	topLayout.setOrientation(LinearLayout.VERTICAL);
	innerLayout.addView(topLayout, new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.WRAP_CONTENT, 1f));
	headerData[0] = new TextView(context, null, android.R.attr.textAppearanceLarge);
	headerData[0].setTextSize(18f);
	if (C.API_LOLLIPOP) {
		headerData[0].setTypeface(GraphicsUtils.TYPEFACE_MEDIUM);
	}
	topLayout.addView(headerData[0], LinearLayout.LayoutParams.MATCH_PARENT,
			LinearLayout.LayoutParams.WRAP_CONTENT);
	headerData[1] = new TextView(context, null, android.R.attr.textAppearanceSmall);
	topLayout.addView(headerData[1], LinearLayout.LayoutParams.MATCH_PARENT,
			LinearLayout.LayoutParams.WRAP_CONTENT);
	headerData[1].setPadding(0, (int) (2f * density), 0, (int) (2f * density));
	headerExpandIcon = new ImageView(context);
	headerExpandIcon.setImageResource(ResourceUtils.getResourceId(context, R.attr.buttonDropDown, 0));
	innerLayout.addView(headerExpandIcon, (int) (24f * density), (int) (24f * density));
	LinearLayout.LayoutParams iconLayoutParams = (LinearLayout.LayoutParams) headerExpandIcon.getLayoutParams();
	iconLayoutParams.gravity = Gravity.BOTTOM;
	iconLayoutParams.setMargins((int) (4f * density), 0, (int) (-6f * density), 0);
	LinearLayout headerAdditional = new LinearLayout(context);
	headerAdditional.setOrientation(LinearLayout.VERTICAL);
	this.headerAdditional = headerAdditional;
	linearLayout.addView(headerAdditional, LinearLayout.LayoutParams.MATCH_PARENT,
			LinearLayout.LayoutParams.WRAP_CONTENT);
	for (int i = 2; i < 6; i += 2) {
		headerData[i] = new TextView(context, null, android.R.attr.textAppearanceLarge);
		headerData[i].setTextSize(16f);
		if (C.API_LOLLIPOP) {
			headerData[i].setTypeface(headerData[0].getTypeface());
		}
		headerData[i].setPadding(0, (int) (8f * density), 0, (int) (4f * density));
		headerAdditional.addView(headerData[i], LinearLayout.LayoutParams.MATCH_PARENT,
				LinearLayout.LayoutParams.WRAP_CONTENT);
		headerData[i + 1] = new TextView(context, null, android.R.attr.textAppearanceSmall);
		headerData[i + 1].setLineSpacing((int) (2f * density), 1f);
		headerAdditional.addView(headerData[i + 1], LinearLayout.LayoutParams.MATCH_PARENT,
				LinearLayout.LayoutParams.WRAP_CONTENT);
		headerData[i + 1].setPadding(0, 0, 0, (int) (2f * density));
	}
	headerData[4].setText(context.getString(R.string.text_configuration));
	LinearLayout radioButtonsContainer = new LinearLayout(context);
	radioButtonsContainer.setOrientation(LinearLayout.VERTICAL);
	radioButtonsContainer.setClickable(true);
	headerAdditional.addView(radioButtonsContainer, LinearLayout.LayoutParams.MATCH_PARENT,
			LinearLayout.LayoutParams.WRAP_CONTENT);
	for (int i = 0; i < sortingData.length; i++) {
		sortingData[i] = new RadioButton(context);
		sortingData[i].setOnCheckedChangeListener(this);
		radioButtonsContainer.addView(sortingData[i], LinearLayout.LayoutParams.WRAP_CONTENT,
				LinearLayout.LayoutParams.WRAP_CONTENT);
		ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) sortingData[i]
				.getLayoutParams();
		if (i == 0) {
			layoutParams.topMargin = (int) (4f * density);
		}
		if (C.API_LOLLIPOP) {
			layoutParams.leftMargin = (int) (-4f * density);
		}
	}
	sortingData[0].setText(context.getString(R.string.text_sort_by_unsorted));
	sortingData[1].setText(context.getString(R.string.text_sort_by_date));
	sortingData[2].setText(context.getString(R.string.text_sort_by_replies));
	sortingData[0].setChecked(true);
	headerView = frameLayout;
}
 
源代码18 项目: SmileEssence   文件: StatusDetailDialogFragment.java
private View getTitleView(MainActivity activity, Account account, Status status) {
    View view = activity.getLayoutInflater().inflate(R.layout.dialog_status_detail, null);
    View statusHeader = view.findViewById(R.id.layout_status_header);
    StatusViewModel statusViewModel = new StatusViewModel(status, account);
    statusHeader = statusViewModel.getView(activity, activity.getLayoutInflater(), statusHeader);
    statusHeader.setClickable(false);
    int background = ((ColorDrawable) statusHeader.getBackground()).getColor();
    view.setBackgroundColor(background);
    ImageView favCountIcon = (ImageView) view.findViewById(R.id.image_status_detail_fav_count);
    ImageView rtCountIcon = (ImageView) view.findViewById(R.id.image_status_detail_rt_count);
    TextView favCountText = (TextView) view.findViewById(R.id.textview_status_detail_fav_count);
    TextView rtCountText = (TextView) view.findViewById(R.id.textview_status_detail_rt_count);
    int favoriteCount = TwitterUtils.getOriginalStatus(status).getFavoriteCount();
    if (favoriteCount == 0) {
        favCountIcon.setVisibility(View.GONE);
        favCountText.setVisibility(View.GONE);
    } else {
        favCountText.setText(Integer.toString(favoriteCount));
    }
    int retweetCount = TwitterUtils.getOriginalStatus(status).getRetweetCount();
    if (retweetCount == 0) {
        rtCountIcon.setVisibility(View.GONE);
        rtCountText.setVisibility(View.GONE);
    } else {
        rtCountText.setText(Integer.toString(retweetCount));
    }
    ImageButton menu = (ImageButton) view.findViewById(R.id.button_status_detail_menu);
    ImageButton message = (ImageButton) view.findViewById(R.id.button_status_detail_reply);
    ImageButton retweet = (ImageButton) view.findViewById(R.id.button_status_detail_retweet);
    ImageButton favorite = (ImageButton) view.findViewById(R.id.button_status_detail_favorite);
    ImageButton delete = (ImageButton) view.findViewById(R.id.button_status_detail_delete);
    menu.setOnClickListener(this);
    message.setOnClickListener(this);
    retweet.setOnClickListener(this);
    favorite.setOnClickListener(this);
    delete.setOnClickListener(this);
    if (isNotRetweetable(account, status)) {
        retweet.setVisibility(View.GONE);
    } else if (isRetweetDeletable(account, status)) {
        retweet.setImageDrawable(getResources().getDrawable(R.drawable.icon_retweet_on));
        retweet.setTag(status.getId());
    } else {
        retweet.setTag(-1L);
    }
    favorite.setTag(statusViewModel.isFavorited());
    if (statusViewModel.isFavorited()) {
        favorite.setImageDrawable(getResources().getDrawable(R.drawable.icon_favorite_on));
    }
    boolean deletable = isDeletable(account, status);
    delete.setVisibility(deletable ? View.VISIBLE : View.GONE);
    LinearLayout commandsLayout = (LinearLayout) view.findViewById(R.id.linearlayout_status_detail_menu);
    commandsLayout.setClickable(true);
    ArrayList<Command> commands = getCommands(activity, status, account);
    Command.filter(commands);
    for (final Command command : commands) {
        View commandView = command.getView(activity, activity.getLayoutInflater(), null);
        commandView.setBackgroundColor(getResources().getColor(R.color.transparent));
        commandView.setOnClickListener(new ListItemClickListener(activity, new Runnable() {
            @Override
            public void run() {
                command.execute();
                dismiss();
            }
        }));
        commandsLayout.addView(commandView);
    }
    return view;
}
 
源代码19 项目: freemp   文件: AdpPlaylist.java
@Override
public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
    final LinearLayout linearLayout = new LinearLayout(activity);
    linearLayout.setOrientation(LinearLayout.VERTICAL);

    int dpAsPixels = (int) (10 * scale + 0.5f);
    linearLayout.setPadding(dpAsPixels, dpAsPixels, dpAsPixels, dpAsPixels);

    final ClsTrack o = data.get(groupPosition).getPlaylists().get(childPosition);

    final TextView artist = new TextView(activity);
    //artist.setTextAppearance(activity,android.R.attr.textAppearanceMedium);
    artist.setTextSize(TypedValue.COMPLEX_UNIT_PX, med);
    artist.setText(o.getArtist());

    final TextView title = new TextView(activity);
    title.setTextSize(TypedValue.COMPLEX_UNIT_PX, sml);
    title.setText(o.getTitle());

    linearLayout.addView(artist);
    linearLayout.addView(title);

    //selected
    if (o.isSelected()) {
        title.setTextColor(Color.parseColor("#FDC332"));
    } else {
        title.setTextColor(Color.GRAY);
    }

    //selection
    final int posGroup = groupPosition;
    final int posChild = childPosition;
    linearLayout.setClickable(true);
    linearLayout.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (!o.isSelected()) {
                title.setTextColor(Color.parseColor("#FDC332"));
            } else {
                title.setTextColor(Color.GRAY);
            }
            o.setSelected(!o.isSelected());

            ClsArrTrack group = data.get(posGroup);
            ArrayList<ClsTrack> tracks = group.getPlaylists();

            ClsTrack t = tracks.get(posChild);
            t.setSelected(o.isSelected());

            tracks.set(posChild, t);

            data.set(posGroup, group);
            invalidate();
        }
    });
    return linearLayout;
}
 
源代码20 项目: open-rmbt   文件: RMBTSyncEnterCodeFragment.java
@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState)
{
    
    view = inflater.inflate(R.layout.sync_enter_code, container, false);
    
    syncButton = (Button) view.findViewById(R.id.button);
    
    overlay = (LinearLayout) view.findViewById(R.id.overlay);
    
    codeField = (EditText) view.findViewById(R.id.code);
    
    final RMBTSyncEnterCodeFragment tmp = this;
    
    listener = new OnClickListener()
    {
        @Override
        public void onClick(final View v)
        {
            
            final String syncCode = codeField.getText().toString().toUpperCase(Locale.US);
            
            if (syncCode.length() == 12)
            {
                if (syncTask == null || syncTask != null || syncTask.isCancelled())
                {
                    overlay.setVisibility(View.VISIBLE);
                    overlay.setClickable(true);
                    overlay.bringToFront();
                    
                    syncButton.setOnClickListener(null);
                    // codeField.setClickable(false);
                    
                    syncTask = new CheckSyncTask(getActivity());
                    
                    syncTask.setEndTaskListener(tmp);
                    syncTask.execute(syncCode);
                }
            }
            else
                codeField.setError(getActivity().getString(R.string.sync_enter_code_length));
        }
    };
    
    codeField.setOnEditorActionListener(new OnEditorActionListener()
    {
        @Override
        public boolean onEditorAction(final TextView v, final int actionId, final KeyEvent event)
        {
            listener.onClick(v);
            return true;
        }
    });
    
    syncButton.setOnClickListener(listener);
    
    return view;
}