Java Code Examples for android.widget.LinearLayout.getChildAt()

The following are Jave code examples for showing how to use getChildAt() of the android.widget.LinearLayout class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: Orin   File: BreadCrumbLayout.java   View Source Code Vote up 7 votes
private TextView invalidateActivated(View view, final boolean isActive, final boolean noArrowIfAlone, final boolean allowArrowVisible) {
    int contentColor = isActive ? contentColorActivated : contentColorDeactivated;
    LinearLayout child = (LinearLayout) view;
    TextView tv = (TextView) child.getChildAt(0);
    tv.setTextColor(contentColor);
    ImageView iv = (ImageView) child.getChildAt(1);
    iv.setColorFilter(contentColor, PorterDuff.Mode.SRC_IN);
    if (noArrowIfAlone && getChildCount() == 1)
        iv.setVisibility(View.GONE);
    else if (allowArrowVisible)
        iv.setVisibility(View.VISIBLE);
    else
        iv.setVisibility(View.GONE);
    return tv;
}
 
Example 2
Project: bikedeboa-android   File: BindingAdapters.java   View Source Code Vote up 7 votes
@BindingAdapter({"stars"})
public static void setStars(LinearLayout linearLayout, float rating) {

	Context context = linearLayout.getContext();
	int color = AssetHelper.getColorFromScore(rating);

	// Child 0 is the textView with the written score
	Drawable roundedBackground = ContextCompat.getDrawable(context, R.drawable.rounded_edges);
	roundedBackground.setColorFilter(color, PorterDuff.Mode.ADD);
	linearLayout.getChildAt(0).setBackground(roundedBackground);

	int nStars = Math.round(rating);
	for (int i = 1; i <= nStars; ++i) {
		ImageView imageView = (ImageView) linearLayout.getChildAt(i);
		imageView.setColorFilter(color);
	}
}
 
Example 3
Project: financisto1-holo   File: RecurActivity.java   View Source Code Vote up 6 votes
private View selectInLayout(LinearLayout layout, Object tag) {
	View selected = null;
	int count = layout.getChildCount();
	for (int i = 0; i<count; i++) {
		View v = layout.getChildAt(i);
		if (tag == v.getTag()) {
			selected = v;				
		} else {
			v.setVisibility(View.GONE);
		}
	}
	if (selected != null) {
		selected.setVisibility(View.VISIBLE);
	}
	return selected;
}
 
Example 4
Project: xlight_android_native   File: SplashActivity.java   View Source Code Vote up 6 votes
/**
     * 初始化底部小点
     */
    private void initPoint(int views) {
        LinearLayout linearLayout = (LinearLayout) findViewById(R.id.point);

        points = new ImageView[views];

        //循环取得小点图片
        for (int i = 0; i < views; i++) {
            //得到一个LinearLayout下面的每一个子元素
            points[i] = (ImageView) linearLayout.getChildAt(i);
            //默认都设为灰色
            points[i].setEnabled(true);
            //给每个小点设置监听
//            points[i].setOnClickListener(this);
            //设置位置tag,方便取出与当前位置对应
            points[i].setTag(i);
        }

        //设置当面默认的位置
        currentIndex = 0;
        //设置为白色,即选中状态
        points[currentIndex].setEnabled(false);
    }
 
Example 5
Project: AssistantBySDK   File: LingjuCheckListBox.java   View Source Code Vote up 6 votes
private void init(Context context){
	this.mContext=context;
	LayoutInflater inflater=LayoutInflater.from(context);
	inflater.inflate(R.layout.call_select_dialog, this);
	if(list!=null){
		setList(list, title);
	}
	else if(this.title!=null){
		LinearLayout v=(LinearLayout) getChildAt(0);
		LinearLayout v1=(LinearLayout) v.getChildAt(0);
		titleText=(TextView)v1.getChildAt(0);
		closeBT=(ImageView) v1.getChildAt(1);
		closeBT.setOnTouchListener(defaultTounchListener);
		titleText.setText(this.title);
	}
}
 
Example 6
Project: decoy   File: ChatRoomMsgViewHolderBase.java   View Source Code Vote up 6 votes
private void setContent() {
    if (!isShowBubble() && !isMiddleItem()) {
        return;
    }

    LinearLayout bodyContainer = (LinearLayout) view.findViewById(R.id.message_item_body);

    // 调整container的位置
    int index = isReceivedMessage() ? 0 : 3;
    if (bodyContainer.getChildAt(index) != contentContainer) {
        bodyContainer.removeView(contentContainer);
        bodyContainer.addView(contentContainer, index);
    }

    if (isMiddleItem()) {
        setGravity(bodyContainer, Gravity.CENTER);
    } else {
        if (isReceivedMessage()) {
            setGravity(bodyContainer, Gravity.LEFT);
            contentContainer.setBackgroundResource(leftBackground());
        } else {
            setGravity(bodyContainer, Gravity.RIGHT);
            contentContainer.setBackgroundResource(rightBackground());
        }
    }
}
 
Example 7
Project: MenuSet   File: SlideMenu.java   View Source Code Vote up 6 votes
/**
 * 设置子View和自己的宽和高
 * @param widthMeasureSpec
 * @param heightMeasureSpec
 */
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    if (!mMeasureOnce) {
        //初始化控件
        mWapper =(LinearLayout)getChildAt(0);
        mMenu = (ViewGroup)mWapper.getChildAt(0);
        mContent =(ViewGroup)mWapper.getChildAt(1);
        mMenuWidth = mScreenWidth - mMenuRightPadding;
        mMenu.getLayoutParams().width = mMenuWidth;
        mContent.getLayoutParams().width = mScreenWidth;

        //mCanScrollArea = getMeasuredWidth()/5;
        mCanScrollArea = 40;
    }
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);

}
 
Example 8
Project: Orin   File: BreadCrumbLayout.java   View Source Code Vote up 6 votes
public void addCrumb(@NonNull Crumb crumb, boolean refreshLayout) {
    LinearLayout view = (LinearLayout) LayoutInflater.from(getContext()).inflate(R.layout.bread_crumb, this, false);
    view.setTag(mCrumbs.size());
    view.setOnClickListener(this);

    ImageView iv = (ImageView) view.getChildAt(1);
    if (Build.VERSION.SDK_INT >= 19 && iv.getDrawable() != null) {
        iv.getDrawable().setAutoMirrored(true);
    }
    iv.setVisibility(View.GONE);

    mChildFrame.addView(view, new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    mCrumbs.add(crumb);
    if (refreshLayout) {
        mActive = mCrumbs.size() - 1;
        requestLayout();
    }
    invalidateActivatedAll();
}
 
Example 9
Project: GitHub   File: WheelView.java   View Source Code Vote up 5 votes
/**
 * Calculates desired height for layout
 *
 * @param layout the source layout
 * @return the desired layout height
 */
private int getDesiredHeight(LinearLayout layout) {
    if (layout != null && layout.getChildAt(0) != null) {
        itemHeight = layout.getChildAt(0).getMeasuredHeight();
    }
    
    int desired = itemHeight * visibleItems - itemHeight * ITEM_OFFSET_PERCENT / 50;
    
    return Math.max(desired, getSuggestedMinimumHeight());
}
 
Example 10
Project: AssistantBySDK   File: WheelView.java   View Source Code Vote up 5 votes
/**
 * Calculates desired height for layout
 * 
 * @param layout
 *            the source layout
 * @return the desired layout height
 */
private int getDesiredHeight(LinearLayout layout) {
	if (layout != null && layout.getChildAt(0) != null) {
		itemHeight = layout.getChildAt(0).getMeasuredHeight();
	}

	int desired = itemHeight * visibleItems - itemHeight * ITEM_OFFSET_PERCENT / 50;

	return Math.max(desired, getSuggestedMinimumHeight());
}
 
Example 11
Project: FastAndroid   File: CallUserGridView.java   View Source Code Vote up 5 votes
public void removeChild(String childId) {
    int containerCount = linearLayout.getChildCount();

    LinearLayout lastContainer = null;
    List<LinearLayout> containerList = new ArrayList<>();
    for (int i = 0; i < containerCount; i++) {
        LinearLayout container = (LinearLayout) linearLayout.getChildAt(i);
        containerList.add(container);
    }
    for (LinearLayout resultContainer : containerList) {
        if (lastContainer == null) {
            LinearLayout child = (LinearLayout) resultContainer.findViewWithTag(childId);
            if (child != null) {
                resultContainer.removeView(child);
                if (resultContainer.getChildCount() == 0) {
                    linearLayout.removeView(resultContainer);
                    break;
                } else {
                    lastContainer = resultContainer;
                }
            }
        } else {
            View view = resultContainer.getChildAt(0);
            resultContainer.removeView(view);
            lastContainer.addView(view);
            if (resultContainer.getChildCount() == 0) {
                linearLayout.removeView(resultContainer);
                break;
            } else {
                lastContainer = resultContainer;
            }
        }
    }
}
 
Example 12
Project: Tribe   File: PullToZoomScrollView.java   View Source Code Vote up 5 votes
/**
 * 将记录的值设置到控件上,并只让控件设置一次
 * @param widthMeasureSpec
 * @param heightMeasureSpec
 */
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    if(!isonce) {
        mParentView = (LinearLayout) this.getChildAt(0);
        mTopView = (ViewGroup) mParentView.getChildAt(0);
        mTopView.getLayoutParams().height = mTopViewHeight;
        isonce=true;
    }
}
 
Example 13
Project: edslider   File: EdSliderView.java   View Source Code Vote up 5 votes
/**
 * Animate the views too look more lively
 */
public void dismiss()
{
    LinearLayout layout = (LinearLayout) getChildAt(0);

    for (int i = 0; i < layout.getChildCount(); i++)
    {
        View v = layout.getChildAt(i);
        v.setScaleX(1);
        v.setScaleY(1);
        v.animate().cancel();
        v.animate().translationY(isReversed ? -v.getHeight() :v.getHeight())
                .scaleX(0).scaleY(0).setDuration(100)
                .setStartDelay(80 * i)
                .setInterpolator(null)
                .start();
    }
    // hide view when finish animating
    new Handler().postDelayed(new Runnable()
    {
        @Override
        public void run()
        {
            manager.dismiss();
        }
    }, 150 * layout.getChildCount());
}
 
Example 14
Project: TaipeiTechRefined   File: CourseTableLayout.java   View Source Code Vote up 5 votes
private void resetCourseTable() {
    for (int i = 1; i < TABLE_ROW; i++) {
        for (int j = 1; j < TABLE_COL; j++) {
            LinearLayout tr = (LinearLayout) courseContainer.getChildAt(i);
            CourseBlock text = (CourseBlock) tr.getChildAt(j);
            text.resetBlock();
        }
    }
    isDisplayABCD = false;
    isDisplaySat = false;
    isDisplaySun = false;
    isDisplayNoTime = false;
    requestLayout();
}
 
Example 15
Project: Hotspot-master-devp   File: WheelView.java   View Source Code Vote up 5 votes
/**
 * Calculates desired height for layout
 * 
 * @param layout
 *            the source layout
 * @return the desired layout height
 */
private int getDesiredHeight(LinearLayout layout) {
	if (layout != null && layout.getChildAt(0) != null) {
		itemHeight = layout.getChildAt(0).getMeasuredHeight();
	}

	int desired = itemHeight * visibleItems - itemHeight
			* ITEM_OFFSET_PERCENT / 50;

	return Math.max(desired, getSuggestedMinimumHeight());
}
 
Example 16
Project: LeCatApp   File: MyToast.java   View Source Code Vote up 5 votes
public static void showTextToast(Context context, String msg) {
    if (toast == null) {
        toast = Toast.makeText(context, msg, Toast.LENGTH_SHORT);
    } else {
        toast.setText(msg);
    }

    LinearLayout linearLayout = (LinearLayout) toast.getView();
    TextView messageTextView = (TextView) linearLayout.getChildAt(0);
    messageTextView.setTextColor(context.getResources().getColor(R.color.white));
    toast.show();
}
 
Example 17
Project: Expert-Android-Programming   File: NotificationPreferenceActivity.java   View Source Code Vote up 5 votes
private void enableAllChildren(LinearLayout parent, boolean b) {

        try {
            for (int i = 0; i < parent.getChildCount(); i++) {
                View v = parent.getChildAt(i);
                v.setSelected(b);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
 
Example 18
Project: AOdia   File: OperationFragment.java   View Source Code Vote up 5 votes
public void addNewOpeView(OperationView opeView){
    final LinearLayout listView=(LinearLayout) findViewById(R.id.opeListView);
    for(int i=0;i<listView.getChildCount();i++){
        if(listView.getChildAt(i)==opeView){
            AOdiaOperation ope=new AOdiaOperation(diaFile,diaNum);
            diaFile.operationList.get(diaNum).add(i,ope);
            listView.addView(new OperationView(getActivity(),this,ope,diaFile,fileNum,diaNum),i);
            break;
        }
    }
}
 
Example 19
Project: AC2RD   File: ThemeManager.java   View Source Code Vote up 4 votes
public void setAlertDialog(Context context, Dialog dialog)
{
	try
	{
		SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
		int themeSet = Integer.parseInt(sharedPreferences.getString("preferences_theme_set", "0"));
		int colorThemeSet = Integer.parseInt(sharedPreferences.getString("preferences_color_theme_set", "7"));
		
		ViewGroup decorView = (ViewGroup) dialog.getWindow().getDecorView();
		if (decorView == null)
		{
			return;
		}
		
		FrameLayout windowContentView = (FrameLayout) decorView.getChildAt(0);
		if (windowContentView == null)
		{
			return;
		}
		
		FrameLayout contentView = (FrameLayout) windowContentView.getChildAt(0);
		if (contentView == null)
		{
			return;
		}
		
		LinearLayout parentPanel = (LinearLayout) contentView.getChildAt(0);
		if (parentPanel == null)
		{
			return;
		}
		
		LinearLayout topPanel = (LinearLayout) parentPanel.getChildAt(0);
		if (topPanel == null)
		{
			return;
		}
		
		View titleDivider = topPanel.getChildAt(2);
		if (titleDivider == null)
		{
			return;
		}
		else
		{
			titleDivider.setBackgroundColor(context.getResources().getColor(color[themeSet][colorThemeSet]));
		}	
		
		LinearLayout titleTemplate = (LinearLayout) topPanel.getChildAt(1);
		if (titleTemplate == null)
		{
			return;
		}
		
		TextView alertTitle = (TextView) titleTemplate.getChildAt(1);
		if (alertTitle == null)
		{
			return;
		}
		else
		{
			alertTitle.setTextColor(context.getResources().getColor(color[themeSet][colorThemeSet]));
		}
	}
	catch (Exception e)
	{

	}
}
 
Example 20
Project: ChartProgressBar-Android   File: ChartProgressBar.java   View Source Code Vote up 4 votes
public void enableBar(int index) {

		final int barsCount = ((LinearLayout) this.getChildAt(0)).getChildCount();

		for (int i = 0; i < barsCount; i++) {

			FrameLayout rootFrame = (FrameLayout) ((LinearLayout) this.getChildAt(0)).getChildAt(i);

			int rootChildCount = rootFrame.getChildCount();

			for (int j = 0; j < rootChildCount; j++) {

				if ((int) rootFrame.getTag() != index)
					continue;

				rootFrame.setEnabled(true);
				rootFrame.setClickable(true);

				View childView = rootFrame.getChildAt(j);
				if (childView instanceof LinearLayout) {
					//bar
					LinearLayout barContainerLinear = ((LinearLayout) childView);
					int barContainerCount = barContainerLinear.getChildCount();

					for (int k = 0; k < barContainerCount; k++) {

						View view = barContainerLinear.getChildAt(k);

						if (view instanceof Bar) {

							Bar bar = (Bar) view;

							LayerDrawable layerDrawable = (LayerDrawable) bar.getProgressDrawable();
							layerDrawable.mutate();

							ScaleDrawable scaleDrawable = (ScaleDrawable) layerDrawable.getDrawable(1);

							GradientDrawable progressLayer = (GradientDrawable) scaleDrawable.getDrawable();

							if (progressLayer != null) {

								if (mProgressColor > 0)
									progressLayer.setColor(ContextCompat.getColor(mContext, mProgressColor));
								else
									progressLayer.setColor(ContextCompat.getColor(mContext, android.R.color.darker_gray));
							}
						} else {
							TextView titleTxtView = (TextView) view;
							if (mProgressDisableColor > 0)
								titleTxtView.setTextColor(ContextCompat.getColor(mContext, mBarTitleColor));
							else
								titleTxtView.setTextColor(ContextCompat.getColor(mContext, android.R.color.darker_gray));
						}
					}
				}
			}
		}
	}