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

The following are Jave code examples for showing how to use getParent() 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: Vidsta   File: ListenerHelper.java   View Source Code Vote up 6 votes
static void createListenerLog(LinearLayout messagesContainer, String text) {
    String currentDateTime = new SimpleDateFormat("HH:mm:ss.SSS", Locale.getDefault()).format(new Date());
    TextView textView = new TextView(messagesContainer.getContext());
    textView.setTextColor(Color.WHITE);
    textView.setTextSize(14);
    textView.setText(currentDateTime + ": " + text);

    messagesContainer.addView(textView);
    final ScrollView scrollView = (ScrollView)messagesContainer.getParent();
    scrollView.post(new Runnable() {
        public void run() {
            scrollView.fullScroll(ScrollView.FOCUS_DOWN);
        }
    });
}
 
Example 2
Project: android-MaterialPillsBox   File: MaterialPillsBox.java   View Source Code Vote up 5 votes
@Override
public void onClick(View v) {
    if (v instanceof ImageView) {//onClick CloseIcon
        //v.getParent() -> parent of closeIcon
        LinearLayout lnlChild = (LinearLayout) v.getParent();
        LinearLayout lnlContainer = (LinearLayout) lnlChild.getParent();
        int pillPosition = (int) (lnlContainer).getTag();

        if (onPillClickListener != null) {
            onPillClickListener.onCloseIconClick(this, pillPosition);
        }

    } else {
        //onClick for lnlContainer
        int linearLayoutPosition = (int) v.getTag();
        PillEntity pillEntity = (PillEntity) (objectList.get(linearLayoutPosition));
        if (selectionMode == DEFAULT_MODE_MULTI_SELECTION) {
            if (pillEntity.isPressed()) {
                pillEntity.setPressed(false);
                v.setBackgroundResource(backgroundPill);
            } else {
                pillEntity.setPressed(true);
                v.setBackgroundResource(backgroundPillSelected);
            }
        }
        if (onPillClickListener != null) {
            onPillClickListener.onPillClick(this, linearLayoutPosition);
        }
    }
}
 
Example 3
Project: microMathematics   File: ViewUtils.java   View Source Code Vote up 5 votes
/**
 * Procedure returns the layout depth of this term related to mainView
 */
public static int getLayoutDepth(LinearLayout l)
{
    int retValue = 0;
    if (l == null)
    {
        return retValue;
    }
    ViewParent p = l.getParent();
    while (p != null)
    {
        if (p instanceof TwoDScrollView)
        {
            if (((TwoDScrollView) p).getId() == R.id.main_scroll_view)
            {
                break;
            }
        }
        if (p instanceof FormulaBase && p.getParent() == null)
        {
            retValue += 2;
            break;
        }
        retValue++;
        p = p.getParent();
    }
    return retValue;
}