Java Code Examples for android.widget.LinearLayout#setFocusable()

The following examples show how to use android.widget.LinearLayout#setFocusable() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
public void initMenuSubItem() {
	mMenuListLayout.removeAllViews();
	for (int i = 0; i < mMenuVO.subItems.size(); i++) {
	    final MPWindowMenuItemVO menuItemVO = mMenuVO.subItems.get(i);
		LinearLayout layoutMenuItem = (LinearLayout) LayoutInflater.from(mContext).inflate(EUExUtil.getResLayoutID("platform_mp_window_popmenu_item"), null);
		layoutMenuItem.setFocusable(true);
		TextView tvMenuItemTitle = (TextView) layoutMenuItem.findViewById(EUExUtil.getResIdID("platform_mp_window_pop_item_title_textview"));
		View menuItemDecline = layoutMenuItem.findViewById(EUExUtil.getResIdID("platform_mp_window_pop_item_line"));
		if (i == mMenuVO.subItems.size()-1) {
			//最后一个不加分割线
			menuItemDecline.setVisibility(View.GONE);
		}
		tvMenuItemTitle.setText(menuItemVO.itemTitle);
		layoutMenuItem.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
                   mPopMenuClickListener.onClick(menuItemVO.itemId);
				dismiss();
			}
		});
		mMenuListLayout.addView(layoutMenuItem);
	}
	mMenuListLayout.setVisibility(View.VISIBLE);
}
 
Example 2
@Override
public ChannelAdapter.ViewHolder onCreateViewHolder(ViewGroup parent,
                                                    int viewType) {
    // create a new view
    LinearLayout v = (LinearLayout) LayoutInflater.from(parent.getContext())
            .inflate(R.layout.suggested_item, parent, false);
    v.setFocusable(true);
    v.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    ViewHolder vh = new ViewHolder(v);
    return vh;
}
 
Example 3
Source Project: AndroidCrashHelper   File: CrashActivity.java    License: MIT License 5 votes vote down vote up
private View buildCustomView() {
    LinearLayout rootLayout = new LinearLayout(this);
    rootLayout.setOrientation(LinearLayout.VERTICAL);
    rootLayout.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    rootLayout.setFocusable(true);
    rootLayout.setFocusableInTouchMode(true);
    ScrollView scrollView = new ScrollView(this);
    scrollView.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1.0f));
    LinearLayout scrollableView = new LinearLayout(this);
    scrollableView.setOrientation(LinearLayout.VERTICAL);
    scrollView.addView(scrollableView);
    TextView traceView = new TextView(this);
    traceView.setPadding(10, 10, 10, 10);
    traceView.append(deviceInfo);
    traceView.append(stackTrace);
    scrollableView.addView(traceView);
    rootLayout.addView(scrollView);
    Button button = new Button(this);
    button.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    button.setBackgroundColor(Color.TRANSPARENT);
    button.setText("我知道了");
    button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            showDialog();
        }
    });
    rootLayout.addView(button);
    return rootLayout;
}
 
Example 4
Source Project: AndroidCrashHelper   File: CrashActivity.java    License: MIT License 5 votes vote down vote up
private View buildCustomView() {
    LinearLayout rootLayout = new LinearLayout(this);
    rootLayout.setOrientation(LinearLayout.VERTICAL);
    rootLayout.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    rootLayout.setFocusable(true);
    rootLayout.setFocusableInTouchMode(true);
    ScrollView scrollView = new ScrollView(this);
    scrollView.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1.0f));
    LinearLayout scrollableView = new LinearLayout(this);
    scrollableView.setOrientation(LinearLayout.VERTICAL);
    scrollView.addView(scrollableView);
    TextView traceView = new TextView(this);
    traceView.setPadding(10, 10, 10, 10);
    traceView.append(deviceInfo);
    traceView.append(stackTrace);
    scrollableView.addView(traceView);
    rootLayout.addView(scrollView);
    Button button = new Button(this);
    button.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    button.setBackgroundColor(Color.TRANSPARENT);
    button.setText("我知道了");
    button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            showDialog();
        }
    });
    rootLayout.addView(button);
    return rootLayout;
}
 
Example 5
private LinearLayout getDividerView(LinearLayout convertView, ViewGroup parent) {
    if (convertView == null) {
        return (LinearLayout) LayoutInflater.from(parent.getContext()).inflate(R.layout.line_separator, parent, false);
    }
    convertView.setOnClickListener(null);
    convertView.setEnabled(false);
    convertView.setFocusable(false);
    return convertView;
}
 
Example 6
public MPPopMenu(Context context, MPWindowMenuVO menuVO, int width, int height, PopMenuClickListener popMenuClickListener) {
	this.mContext = context;
	this.mWidth = width;
	this.mHeight = height;
	mMenuVO = menuVO;
	mPopMenuClickListener = popMenuClickListener;
	mContainerView = LayoutInflater.from(context).inflate(EUExUtil.getResLayoutID("platform_mp_window_popmenu_layout"), null);
	//浮动菜单外层layout
	mMenuListLayout = (LinearLayout) mContainerView.findViewById(EUExUtil.getResIdID("platform_mp_window_menu_items_container"));
	//初始化浮动菜单内部的子项目
       initMenuSubItem();
	mMenuListLayout.setFocusableInTouchMode(true);
	mMenuListLayout.setFocusable(true);
	mPopupWindow = new PopupWindow(mContainerView, width == 0 ? LayoutParams.WRAP_CONTENT : width, height == 0 ? LayoutParams.WRAP_CONTENT : height);
}
 
Example 7
Source Project: TiAndroidAutofocus   File: ViewProxy.java    License: MIT License 5 votes vote down vote up
public ExampleView(TiViewProxy proxy) {
	super(proxy);
	LinearLayout view = new LinearLayout( proxy.getActivity() );
	view.setFocusable( true );
	view.setFocusableInTouchMode( true );
	setNativeView( view );
}
 
Example 8
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);
}
 
Example 9
Source Project: LauncherTV   File: ApplicationFragment.java    License: Apache License 2.0 4 votes vote down vote up
private void createApplications() {
	mContainer.removeAllViews();

	mGridX = mSetup.getGridX();
	mGridY = mSetup.getGridY();

	if (mGridX < 2)
		mGridX = 2;
	if (mGridY < 1)
		mGridY = 1;

	int marginX = Utils.getPixelFromDp(getContext(), mSetup.getMarginX());
	int marginY = Utils.getPixelFromDp(getContext(), mSetup.getMarginY());

	boolean showNames = mSetup.showNames();

	mApplications = new ApplicationView[mGridY][mGridX];

	int position = 0;
	for (int y = 0; y < mGridY; y++) {
		LinearLayout ll = new LinearLayout(getContext());
		ll.setOrientation(LinearLayout.HORIZONTAL);
		ll.setGravity(Gravity.CENTER_VERTICAL);
		ll.setFocusable(false);
		ll.setLayoutParams(new LinearLayout.LayoutParams(
				LinearLayout.LayoutParams.MATCH_PARENT, 0, 1
		));

		for (int x = 0; x < mGridX; x++) {
			ApplicationView av = new ApplicationView(getContext());
			av.setOnClickListener(this);
			av.setOnLongClickListener(this);
			av.setOnMenuOnClickListener(new View.OnClickListener() {
				@Override
				public void onClick(View v) {
					onLongClick(v);
				}
			});
			av.setPosition(position++);
			av.showName(showNames);
			if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) {
				av.setId(0x00FFFFFF + position);
			} else {
				av.setId(View.generateViewId());
			}
			LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.MATCH_PARENT, 1);
			lp.setMargins(marginX, marginY, marginX, marginY);
			av.setLayoutParams(lp);
			ll.addView(av);
			mApplications[y][x] = av;
		}
		mContainer.addView(ll);
	}

	updateApplications();
	setApplicationOrder();
}
 
Example 10
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);
}
 
Example 11
Source Project: K-Sonic   File: PlusMinusNum.java    License: MIT License 4 votes vote down vote up
private void initView() {
    setOrientation(LinearLayout.HORIZONTAL);

    // [email protected] Layout
    centerLL = new LinearLayout(getContext());
    editText = new EditText(getContext());
    editText.setInputType(InputType.TYPE_CLASS_NUMBER);//TYPE_NULL
    editText.setText(String.valueOf(num));
    editText.setTextColor(0xff229EBF);
    editText.setBackgroundResource(R.drawable.num_edit);
    editText.setPadding(0, 0, 0, 0);
    editText.setGravity(Gravity.CENTER);
    editText.setMinimumWidth(ediTextMinimumWidth);
    LayoutParams ediTextLP = new LayoutParams(
            LinearLayout.LayoutParams.WRAP_CONTENT,
            LinearLayout.LayoutParams.MATCH_PARENT);
    editText.setLayoutParams(ediTextLP);

    LayoutParams centerLP = new LayoutParams(
            LinearLayout.LayoutParams.WRAP_CONTENT,
            LinearLayout.LayoutParams.MATCH_PARENT);
    centerLP.gravity = Gravity.CENTER;
    centerLL.setLayoutParams(centerLP);
    centerLL.setFocusable(true);
    centerLL.setFocusableInTouchMode(true);


    // [email protected]/right Layout
    minusButton = new Button(getContext());
    minusButton.setText(minusButtonText);
    minusButton.setTextColor(0xff666666);
    minusButton.setTag(minusButtonText);
    minusButton.setBackgroundResource(R.drawable.num_minus);
    minusButton.setPadding(0, 0, 0, 0);

    plusButton = new Button(getContext());
    plusButton.setText(plusButtonText);
    plusButton.setTextColor(0xff666666);
    plusButton.setTag(plusButtonText);
    plusButton.setBackgroundResource(R.drawable.num_plus);
    plusButton.setPadding(0, 0, 0, 0);

    LayoutParams buttonLP = new LayoutParams(
            buttonWidth,
            LinearLayout.LayoutParams.MATCH_PARENT);
    plusButton.setLayoutParams(buttonLP);
    minusButton.setLayoutParams(buttonLP);
}
 
Example 12
private void init() {
    mDensity = getResources().getDisplayMetrics().density;

    mChipsContainer = new RelativeLayout(getContext());
    addView(mChipsContainer);

    // Dummy item to prevent AutoCompleteTextView from receiving focus
    LinearLayout linearLayout = new LinearLayout(getContext());
    ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(0, 0);
    linearLayout.setLayoutParams(params);
    linearLayout.setFocusable(true);
    linearLayout.setFocusableInTouchMode(true);

    mChipsContainer.addView(linearLayout);

    mEditText = new ChipsEditText(getContext(), this);
    RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    layoutParams.topMargin = (int) (SPACING_TOP * mDensity);
    layoutParams.bottomMargin = (int) (SPACING_BOTTOM * mDensity) + mVerticalSpacing;
    mEditText.setLayoutParams(layoutParams);
    mEditText.setMinHeight((int) (CHIP_HEIGHT * mDensity));
    mEditText.setPadding(0, 0, 0, 0);
    mEditText.setLineSpacing(mVerticalSpacing, (CHIP_HEIGHT * mDensity) / mEditText.getLineHeight());
    mEditText.setBackgroundColor(Color.argb(0, 0, 0, 0));
    mEditText.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI | EditorInfo.IME_ACTION_UNSPECIFIED);
    mEditText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS | InputType.TYPE_TEXT_FLAG_MULTI_LINE);
    mEditText.setHint(mChipsHintText);

    mChipsContainer.addView(mEditText);

    mRootChipsLayout = new ChipsVerticalLinearLayout(getContext(), mVerticalSpacing);
    mRootChipsLayout.setOrientation(LinearLayout.VERTICAL);
    mRootChipsLayout.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    mRootChipsLayout.setPadding(0, (int) (SPACING_TOP * mDensity), 0, 0);
    mChipsContainer.addView(mRootChipsLayout);

    initListener();

    if (isInEditMode()) {
        // preview chips
        LinearLayout editModeLinLayout = new LinearLayout(getContext());
        editModeLinLayout.setOrientation(LinearLayout.HORIZONTAL);
        mChipsContainer.addView(editModeLinLayout);

        View view = new Chip("Test Chip", null, new Contact(null, null, "Test", "[email protected]", null)).getView();
        view.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED), MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
        editModeLinLayout.addView(view);

        View view2 = new Chip("Indelible", null, new Contact(null, null, "Test", "[email protected]", null), true).getView();
        view2.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED), MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
        editModeLinLayout.addView(view2);
    }
}
 
Example 13
private void addTab(final int position, String title, Drawable drawable) {
	
	LinearLayout tab = new LinearLayout(getContext());
	tab.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, UEMethod.dp2px(getContext(), 52)));
	tab.setGravity(Gravity.CENTER);
	tab.setOrientation(LinearLayout.HORIZONTAL);
	
	RelativeLayout tabContent = new RelativeLayout(getContext());
	tabContent.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT));
	
	RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(UEMethod.dp2px(getContext(), tabImageWidth), UEMethod.dp2px(getContext(), tabImageHeight));
	params.setMargins(0, UEMethod.dp2px(getContext(), 4), 0, 0);
	params.addRule(RelativeLayout.CENTER_HORIZONTAL);
	ImageView imageView = new ImageView(getContext());
	imageView.setImageDrawable(drawable);
	imageView.setLayoutParams(params);
	imageView.setId(1);
	imageView.setScaleType(ScaleType.FIT_CENTER);
	
	RelativeLayout.LayoutParams params2 = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
	params2.addRule(RelativeLayout.BELOW, 1);
	params2.addRule(RelativeLayout.CENTER_HORIZONTAL);
	params2.setMargins(0, 0, 0, 6);
	TextView textView = new TextView(getContext());
	textView.setLayoutParams(params2);
	textView.setText(title);
	textView.setTextSize(tabTextSize);
	textView.setTextColor(tabTextColor);
	textView.setSingleLine();
	if (TextUtils.isEmpty(title)) {
		textView.setVisibility(View.GONE);
	}
	
	RelativeLayout.LayoutParams params3 = new RelativeLayout.LayoutParams(UEMethod.dp2px(getContext(), 10), UEMethod.dp2px(getContext(), 10));
	params3.addRule(RelativeLayout.RIGHT_OF, 1);
	params3.setMargins(0, UEMethod.dp2px(getContext(), 6), 0, 0);
	ImageView noticeImageView = new ImageView(getContext());
	noticeImageView.setLayoutParams(params3);
	noticeImageView.setScaleType(ScaleType.FIT_CENTER);
	
	tabContent.addView(imageView);
	tabContent.addView(textView);
	tabContent.addView(noticeImageView);
	tab.addView(tabContent);
	
	tab.setFocusable(true);
	tab.setOnClickListener(new OnClickListener() {
		@Override
		public void onClick(View v) {
			pager.setEnableScroll(true);
			pager.setCurrentItem(position, autoAnimate);
			pager.setEnableScroll(false);
			selectedPosition = position;
			updateTabStyles();
			if (delegatePageListener != null) {
				delegatePageListener.onPageSelected(position);
			}
		}
	});
	
	tab.setPadding(tabPadding, 0, tabPadding, 0);
	tabsContainer.addView(tab, position, expandedTabLayoutParams);
}