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

The following are Jave code examples for showing how to use getChildAt() of the android.widget.RelativeLayout class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: Instincts-2k17   File: EventDetailActivity.java   Source Code and License Vote up 8 votes
@Override
protected void onActionClick(View action) {
    super.onActionClick(action);
    CardView cardView = (CardView) action;
    RelativeLayout relativeLayout = (RelativeLayout) cardView.getChildAt(0);
    ImageView imageView = (ImageView) relativeLayout.getChildAt(0);
    switch ((int) imageView.getTag()) {
        case R.drawable.ic_call:
            Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" +
                    event.getContact1().split(":")[1]));
            startActivity(intent);
            break;

        case R.drawable.ic_map:
            startActivity(new Intent(EventDetailActivity.this, MapsActivity.class)
                    .putExtra("location", event.getLocation()));
            break;
    }
}
 
Example 2
Project: AssistantBySDK   File: ExpandableListAdapter.java   Source Code and License Vote up 6 votes
@Override
public View getGroupView(int groupPosition, boolean isExpanded,
                         View convertView, ViewGroup parent) {
    if (convertView == null) {
        convertView = inflater.inflate(R.layout.example_list_item, null);
    }
    RelativeLayout l = (RelativeLayout) ((LinearLayout) convertView).getChildAt(1);
    ((ImageView) l.getChildAt(0)).setImageResource((Integer) groups[groupPosition][0]);
    LinearLayout box = (LinearLayout) l.getChildAt(1);
    TextView title = (TextView) box.getChildAt(0);
    title.setText(groups[groupPosition][1].toString());
    ((TextView) box.getChildAt(1)).setText(groups[groupPosition][2].toString());
    if (isExpanded) {
        title.setTextColor(mContext.getResources().getColorStateList(R.color.base_blue));
        ((ImageView) l.getChildAt(2)).setImageResource(R.drawable.more_up);
        if (groupPosition > 0)
            ((LinearLayout) convertView).getChildAt(0).setVisibility(View.VISIBLE);
    } else {
        title.setTextColor(mContext.getResources().getColorStateList(R.color.new_text_color_first));
        ((ImageView) l.getChildAt(2)).setImageResource(R.drawable.more_dowm);
        ((LinearLayout) convertView).getChildAt(0).setVisibility(View.INVISIBLE);
    }
    return convertView;
}
 
Example 3
Project: Artist   File: CanvasActivity.java   Source Code and License Vote up 6 votes
@Override
public void onClick(View view) {
    removeDot();

    RelativeLayout relativeLayout = (RelativeLayout) view;
    FloatingActionButton floatingActionButton = (FloatingActionButton)relativeLayout.getChildAt(0);
    drawView.changeColor(floatingActionButton.getBackgroundTintList().getDefaultColor());

    View dotView = new View(CanvasActivity.this);
    dotView.setTag("dot");
    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(32, 32);
    params.addRule(RelativeLayout.CENTER_IN_PARENT);
    relativeLayout.addView(dotView, params);
    dotView.setBackgroundResource(R.drawable.canvas_circle_color_shape);
    lastColorSelectLayout = relativeLayout;
}
 
Example 4
Project: letv   File: ChannelTabPageIndicator.java   Source Code and License Vote up 6 votes
public void setCurrentItem(int item) {
    if (this.mViewPager != null) {
        if (item != -1 || this.mSelectedTabIndex != item) {
            this.mSelectedTabIndex = item;
            int tabCount = this.mTabLayout.getChildCount();
            for (int i = 0; i < tabCount; i++) {
                RelativeLayout childLayout = (RelativeLayout) this.mTabLayout.getChildAt(i);
                for (int j = 0; j < childLayout.getChildCount(); j++) {
                    boolean isSelected;
                    if (i == item) {
                        isSelected = true;
                    } else {
                        isSelected = false;
                    }
                    View view = childLayout.getChildAt(j);
                    if (view instanceof TabView) {
                        view.setSelected(isSelected);
                        if (isSelected) {
                            animateToTab(item);
                        }
                    } else {
                        view.setSelected(isSelected);
                    }
                }
            }
            this.mViewPager.setCurrentItem(item, false);
        }
    }
}
 
Example 5
Project: BestPracticeApp   File: SwipeCardLayout.java   Source Code and License Vote up 6 votes
void refreshFloor() {
    float translationX = Math.abs(getTranslationX());
    if (translationX <= 300) {

        float p = translationX / 300;

        RelativeLayout parent = (RelativeLayout) getParent();
        View childAt = parent.getChildAt(0);
        if (childAt != this) {
            childAt.setScaleX(mScale + (1 - mScale) * p);
            childAt.setScaleY(mScale + (1 - mScale) * p);
            childAt.setTranslationY(mTranslate - (mTranslate * p));
            parent.invalidate();
        }
    }
}
 
Example 6
Project: FastEc   File: BaseBottomDelegate.java   Source Code and License Vote up 6 votes
@Override
public void onBindView(@Nullable Bundle savedInstanceState, View rootView) {
    final int size = ITEMS.size();
    for (int i = 0; i < size; i++) {
        LayoutInflater.from(getContext()).inflate(R.layout.bottom_item_icon_text_layout, mBottomBar);
        final RelativeLayout item = (RelativeLayout) mBottomBar.getChildAt(i);
        //设置每个item的点击事件
        item.setTag(i);
        item.setOnClickListener(this);
        final IconTextView itemIcon = (IconTextView) item.getChildAt(0);
        final AppCompatTextView itemTitle = (AppCompatTextView) item.getChildAt(1);
        final BottomTabBean bean = TAB_BEANS.get(i);
        //初始化数据
        itemIcon.setText(bean.getICON());
        itemTitle.setText(bean.getTITLE());
        if (i == mIndexDelegate) {
            itemIcon.setTextColor(mClickedColor);
            itemTitle.setTextColor(mClickedColor);
        }
    }
    final ISupportFragment[] delegateArray = ITEM_DELEGATES.toArray(new ISupportFragment[size]);
    getSupportDelegate().loadMultipleRootFragment(R.id.bottom_bar_delegate_container, mIndexDelegate, delegateArray);

}
 
Example 7
Project: GitHub   File: TestSampleCase.java   Source Code and License Vote up 5 votes
public void testView() {
    assertTrue("Parent View is not Relative Layout", view2test instanceof RelativeLayout);
    RelativeLayout relative = (RelativeLayout) view2test;
    assertTrue("expecting Linear Layout", relative.getChildAt(0) instanceof LinearLayout);
    LinearLayout linearLayout = (LinearLayout) relative.getChildAt(0);
    assertEquals("expecting 4 children", linearLayout.getChildCount(), 4);
    assertEquals(linearLayout.getChildAt(0).getClass(), TextView.class);
    assertEquals(linearLayout.getChildAt(1).getClass(), TextView.class);
    assertEquals(linearLayout.getChildAt(2).getClass(), ImageView.class);
    assertEquals(linearLayout.getChildAt(3).getClass(), TextView.class);
}
 
Example 8
Project: SwolyV2   File: MaxesAdapter.java   Source Code and License Vote up 5 votes
public MaxesViewHolder(View view){
    super(view);
    lift = (TextView) view.findViewById(R.id.liftTitle);
    weight = (TextView) view.findViewById(R.id.weight);
    cardLayout = (RelativeLayout) view.findViewById(R.id.relative);
    floatingActionButton = (FloatingActionButton) view.findViewById(R
            .id.additionFAB);
    for(short i =0; i<cardLayout.getChildCount(); i++){
        if(cardLayout.getChildAt(i) instanceof AppCompatButton){
            cardButtons.add((AppCompatButton) cardLayout.getChildAt(i));
        }
    }
    vertMenu = (ImageView) view.findViewById(R.id.cardMenu);
    viewCard = view;
}
 
Example 9
Project: FastEc   File: BaseBottomDelegate.java   Source Code and License Vote up 5 votes
private void resetColor() {
    final int count = mBottomBar.getChildCount();
    for (int i = 0; i < count; i++) {
        final RelativeLayout item = (RelativeLayout) mBottomBar.getChildAt(i);
        final IconTextView itemIcon = (IconTextView) item.getChildAt(0);
        itemIcon.setTextColor(Color.GRAY);
        final AppCompatTextView itemTitle = (AppCompatTextView) item.getChildAt(1);
        itemTitle.setTextColor(Color.GRAY);
    }
}
 
Example 10
Project: FastEc   File: BaseBottomDelegate.java   Source Code and License Vote up 5 votes
@Override
public void onClick(View v) {
    final int tag = (int) v.getTag();
    resetColor();
    final RelativeLayout item = (RelativeLayout) v;
    final IconTextView itemIcon = (IconTextView) item.getChildAt(0);
    itemIcon.setTextColor(mClickedColor);
    final AppCompatTextView itemTitle = (AppCompatTextView) item.getChildAt(1);
    itemTitle.setTextColor(mClickedColor);
    getSupportDelegate().showHideFragment(ITEM_DELEGATES.get(tag), ITEM_DELEGATES.get(mCurrentDelegate));
    //注意先后顺序
    mCurrentDelegate = tag;

}