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

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

源代码1 项目: SoloPi   文件: FileChooseDialogActivity.java
/**
 * 初始化界面
 */
private void initView() {
    // 标题部分
    upperIcon = findViewById(R.id.file_choose_upper);
    titleText = (TextView) findViewById(R.id.file_choose_title);
    currentDirectoryText = (TextView) findViewById(R.id.file_choose_path);
    createIcon = findViewById(R.id.file_choose_create);

    // List
    dirList = (ListView) findViewById(R.id.file_choose_list);

    // button
    positiveButton = (LinearLayout) findViewById(R.id.file_choose_positive_button);
    positiveBtnText = (TextView) positiveButton.getChildAt(0);
    negativeButton = (LinearLayout) findViewById(R.id.file_choose_negative_button);
    negativeBtnText = (TextView) negativeButton.getChildAt(0);
}
 
源代码2 项目: RetroMusicPlayer   文件: BreadCrumbLayout.java
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();
}
 
源代码3 项目: citra_android   文件: MenuFragment.java
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
  View rootView = inflater.inflate(R.layout.fragment_ingame_menu, container, false);

  LinearLayout options = rootView.findViewById(R.id.layout_options);
  for (int childIndex = 0; childIndex < options.getChildCount(); childIndex++)
  {
    Button button = (Button) options.getChildAt(childIndex);

    button.setOnClickListener(this);
  }

  TextView titleText = rootView.findViewById(R.id.text_game_title);
  String title = getArguments().getString(KEY_TITLE);
  if (title != null)
  {
    titleText.setText(title);
  }

  return rootView;
}
 
源代码4 项目: Orin   文件: BreadCrumbLayout.java
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();
}
 
源代码5 项目: AsymmetricGridView   文件: AdapterImpl.java
private LinearLayout initializeLayout(LinearLayout layout) {
  // Clear all layout children before starting
  int childCount = layout.getChildCount();
  for (int j = 0; j < childCount; j++) {
    LinearLayout tempChild = (LinearLayout) layout.getChildAt(j);
    linearLayoutPool.put(tempChild);
    int innerChildCount = tempChild.getChildCount();
    for (int k = 0; k < innerChildCount; k++) {
      View innerView = tempChild.getChildAt(k);
      ViewState viewState = (ViewState) innerView.getTag();
      ObjectPool<AsymmetricViewHolder<?>> pool = viewHoldersMap.get(viewState.viewType);
      pool.put(viewState.viewHolder);
    }
    tempChild.removeAllViews();
  }
  layout.removeAllViews();

  return layout;
}
 
源代码6 项目: DialogUtil   文件: MaterialDialog.java
public void setContentView(View contentView) {
    ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    contentView.setLayoutParams(layoutParams);
    if (contentView instanceof ListView) {
        setListViewHeightBasedOnChildren((ListView) contentView);
    }
    LinearLayout linearLayout = (LinearLayout) mAlertDialogWindow.findViewById(
            R.id.message_content_view);
    if (linearLayout != null) {
        linearLayout.removeAllViews();
        linearLayout.addView(contentView);
    }
    for (int i = 0; i < (linearLayout != null ? linearLayout.getChildCount() : 0); i++) {
        if (linearLayout.getChildAt(i) instanceof AutoCompleteTextView) {
            AutoCompleteTextView autoCompleteTextView
                    = (AutoCompleteTextView) linearLayout.getChildAt(i);
            autoCompleteTextView.setFocusable(true);
            autoCompleteTextView.requestFocus();
            autoCompleteTextView.setFocusableInTouchMode(true);
        }
    }
}
 
源代码7 项目: crosswalk-cordova-android   文件: ErrorUrlTest.java
protected void setUp() throws Exception {
    super.setUp();
    testActivity = this.getActivity();
    containerView = (FrameLayout) testActivity.findViewById(android.R.id.content);
    innerContainer = (LinearLayout) containerView.getChildAt(0);
    testView = (CordovaWebView) innerContainer.getChildAt(0);
}
 
源代码8 项目: Telegram-FOSS   文件: ActionBarMenuItem.java
public void setPopupItemsSelectorColor(int color) {
    if (popupLayout == null) {
        return;
    }
    final LinearLayout layout = popupLayout.linearLayout;
    for (int a = 0, count = layout.getChildCount(); a < count; a++) {
        final View child = layout.getChildAt(a);
        if (child instanceof ActionBarMenuSubItem) {
            ((ActionBarMenuSubItem) child).setSelectorColor(color);
        }
    }
}
 
源代码9 项目: cordova-amazon-fireos   文件: PluginManagerTest.java
protected void setUp() throws Exception {
    super.setUp();
    testActivity = this.getActivity();
    containerView = (FrameLayout) testActivity.findViewById(android.R.id.content);
    innerContainer = (LinearLayout) containerView.getChildAt(0);
    testView = innerContainer.getChildAt(0);
    mWebView = (CordovaWebView) testView;
    pluginMgr = mWebView.pluginManager;

}
 
protected void setUp() throws Exception{
	super.setUp();
	testActivity = this.getActivity();
	containerView = (FrameLayout) testActivity.findViewById(android.R.id.content);
	innerContainer = (LinearLayout) containerView.getChildAt(0);
	testView = innerContainer.getChildAt(0);
	
}
 
源代码11 项目: BehaviorCollect   文件: MainActivity.java
/**
 * 切换时变色
 *
 * @param index
 */
private void changeTabColor(int index) {
    for (int i = 0; i < mLlMainTab.getChildCount(); i++) {

        LinearLayout currentview = (LinearLayout) mLlMainTab.getChildAt(i);
        ImageView currentImage = (ImageView) currentview.getChildAt(0);
        TextView current_TextView = (TextView) currentview.getChildAt(1);
        switch (i) {
            case 0:
                if (index == i) {
                    currentImage.setImageResource(R.mipmap.ic_tab_home_check);
                } else {
                    currentImage.setImageResource(R.mipmap.ic_tab_home_default);
                }
                break;

            case 1:
                if (index == i) {
                    currentImage.setImageResource(R.mipmap.ic_tab_products_check);
                } else {
                    currentImage.setImageResource(R.mipmap.ic_tab_products_default);
                }
                break;

            case 2:
                if (index == i) {
                    currentImage.setImageResource(R.mipmap.ic_tab_my_check);
                } else {
                    currentImage.setImageResource(R.mipmap.ic_tab_my_default);
                }
                break;
        }

        if (i == index) {
            current_TextView.setTextColor(this.getResources().getColor(R.color.main_tab_text_color_select));
        } else {
            current_TextView.setTextColor(this.getResources().getColor(R.color.main_tab_text_color_unselect));
        }
    }
}
 
源代码12 项目: javaide   文件: ColorPickerView.java
public void setColorPreview(LinearLayout colorPreview, Integer selectedColor) {
	if (colorPreview == null)
		return;
	this.colorPreview = colorPreview;
	if (selectedColor == null)
		selectedColor = 0;
	int children = colorPreview.getChildCount();
	if (children == 0 || colorPreview.getVisibility() != View.VISIBLE)
		return;

	for (int i = 0; i < children; i++) {
		View childView = colorPreview.getChildAt(i);
		if (!(childView instanceof LinearLayout))
			continue;
		LinearLayout childLayout = (LinearLayout) childView;
		if (i == selectedColor) {
			childLayout.setBackgroundColor(Color.WHITE);
		}
		ImageView childImage = (ImageView) childLayout.findViewById(R.id.image_preview);
		childImage.setClickable(true);
		childImage.setTag(i);
		childImage.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				if (v == null)
					return;
				Object tag = v.getTag();
				if (tag == null || !(tag instanceof Integer))
					return;
				setSelectedColor((int) tag);
			}
		});
	}
}
 
源代码13 项目: android-project-wo2b   文件: LockViewActivity.java
@Override
protected void initView()
{
	grid_number = (GridView) findViewById(R.id.grid_number);

	generateKeyboard();

	mOldPwd = XPreferenceManager.getString(RockyKeyValues.Keys.ENTRY_PASSWORD, "");
	

	pwd_content = (LinearLayout) findViewById(R.id.pwd_content);
	final int pwd_count = pwd_content.getChildCount();
	pwd_items = new EditText[pwd_count];
	for (int i = 0; i < pwd_count; i++)
	{
		pwd_items[i] = (EditText) pwd_content.getChildAt(i);
		if (mMode == LOCK_MODE_DECODE)
		{
			// 解密
			pwd_items[i].setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
		}
		else
		{
			pwd_items[i].setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
		}

		ViewUtils.hideSoftInput(this, pwd_items[i]);
	}

	pwd_items[0].requestFocus();
	pwd_items[pwd_count - 1].addTextChangedListener(new OnTextInputCompleted());
}
 
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();
        }

    }
 
源代码15 项目: timecat   文件: ColorPickerView.java
public void setColorPreview(LinearLayout colorPreview, Integer selectedColor) {
	if (colorPreview == null)
		return;
	this.colorPreview = colorPreview;
	if (selectedColor == null)
		selectedColor = 0;
	int children = colorPreview.getChildCount();
	if (children == 0 || colorPreview.getVisibility() != View.VISIBLE)
		return;

	for (int i = 0; i < children; i++) {
		View childView = colorPreview.getChildAt(i);
		if (!(childView instanceof LinearLayout))
			continue;
		LinearLayout childLayout = (LinearLayout) childView;
		if (i == selectedColor) {
			childLayout.setBackgroundColor(Color.WHITE);
		}
		ImageView childImage = (ImageView) childLayout.findViewById(R.id.image_preview);
		childImage.setClickable(true);
		childImage.setTag(i);
		childImage.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				if (v == null)
					return;
				Object tag = v.getTag();
				if (tag == null || !(tag instanceof Integer))
					return;
				setSelectedColor((int) tag);
			}
		});
	}
}
 
/**
 * Find the checkbox in the item row and tell us if it's checked
 * @param itemRow linearLayout containing a checkbox
 * @return true if the checkbox is checked
 */
private boolean isItemRowChecked(LinearLayout itemRow){
    for (int i = 0; i < itemRow.getChildCount(); i++) {
        if(itemRow.getChildAt(i) instanceof CheckBox){
            CheckBox check = (CheckBox) itemRow.getChildAt(i);
            return check.isChecked();
        }
    }
    return false;
}
 
源代码17 项目: Phonograph   文件: BreadCrumbLayout.java
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;
}
 
源代码18 项目: MaterialDesignDemo   文件: TabLayoutActivity.java
@Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_tab_layout);
        mTabLayout = (TabLayout) findViewById(R.id.tabLayout);

        // 手动创建Tab
//        for (int i = 0; i < title.length; i++) {
//            TabLayout.Tab tab = mTabLayout.newTab();
//            tab.setText(title[i]);
////            tab.setIcon(R.mipmap.ic_launcher);//icon会显示在文字上面
//            mTabLayout.addTab(tab);
//        }

        // TabLayout与ViewPager结合使用
        mViewPager = (ViewPager) findViewById(R.id.viewPager);
        MyViewPagerAdapter adapter = new MyViewPagerAdapter(getSupportFragmentManager());
        mViewPager.setAdapter(adapter);
//        // 适配器必须重写getPageTitle()方法
//        mTabLayout.setTabsFromPagerAdapter(adapter);
//        // 监听TabLayout的标签选择,当标签选中时ViewPager切换
//        mTabLayout.setOnTabSelectedListener(new TabLayout.ViewPagerOnTabSelectedListener(mViewPager));
//        // 监听ViewPager的页面切换,当页面切换时TabLayout的标签跟着切换
//        mViewPager.setOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(mTabLayout));
        // 关联TabLayout与ViewPager,且适配器必须重写getPageTitle()方法
        mTabLayout.setupWithViewPager(mViewPager);


        mLinearLayout = (LinearLayout) mTabLayout.getChildAt(0);
        // 在所有子控件的中间显示分割线(还可能只显示顶部、尾部和不显示分割线)
        mLinearLayout.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE);
        // 设置分割线的距离本身(LinearLayout)的内间距
        mLinearLayout.setDividerPadding(50);
        // 设置分割线的样式
        mLinearLayout.setDividerDrawable(ContextCompat.getDrawable(this, R.drawable.divider_vertical));
        mLinearLayout.setBackgroundColor(getResources().getColor(R.color.colorPrimaryDark));


        // 为TabLayout设置不同状态下的字体大小(并不能成功)
//        for (int i = 0; i < mTabLayout.getTabCount(); i++) {
//            ((TextView) ((LinearLayout) mLinearLayout.getChildAt(i)).getChildAt(1)).setTextSize(10);
////            ((TextView) ((LinearLayout) ((LinearLayout) mTabLayout.getChildAt(0)).getChildAt(i)).getChildAt(0)).setTextSize(12);
//        }
//        ((TextView) ((LinearLayout) mLinearLayout.getChildAt(mTabLayout.getSelectedTabPosition())).getChildAt(1)).setTextSize(30);
//
//        mTabLayout.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
//            @Override
//            public void onTabSelected(TabLayout.Tab tab) {
//                ((TextView) ((LinearLayout) mLinearLayout.getChildAt(tab.getPosition())).getChildAt(1)).setTextSize(30);
//            }
//
//            @Override
//            public void onTabUnselected(TabLayout.Tab tab) {
//                ((TextView) ((LinearLayout) mLinearLayout.getChildAt(tab.getPosition())).getChildAt(1)).setTextSize(10);
//            }
//
//            @Override
//            public void onTabReselected(TabLayout.Tab tab) {
//
//            }
//        });


        // 自定义指示器(Indicator)的“长度”的两种方法
        // 方法一:反射
//        setIndicator(mTabLayout,10,10);
        // 方法二:查找子控件
        int left = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 10, Resources.getSystem().getDisplayMetrics());
        int right = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 10, Resources.getSystem().getDisplayMetrics());
        for (int i = 0; i < mLinearLayout.getChildCount(); i++) {
            View tabView = mLinearLayout.getChildAt(0);
            LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.MATCH_PARENT, 1);
            params.leftMargin = left;
            params.rightMargin = right;
            tabView.setLayoutParams(params);
        }
    }
 
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));
						}
					}
				}
			}
		}
	}
 
源代码20 项目: open   文件: PeliasSearchViewTest.java
private AutoCompleteTextView getQueryTextView() {
    LinearLayout linearLayout1 = (LinearLayout) peliasSearchView.getChildAt(0);
    LinearLayout linearLayout2 = (LinearLayout) linearLayout1.getChildAt(2);
    LinearLayout linearLayout3 = (LinearLayout) linearLayout2.getChildAt(1);
    return (AutoCompleteTextView) linearLayout3.getChildAt(0);
}