Example usage for android.content.res TypedArray getResourceId

List of usage examples for android.content.res TypedArray getResourceId

Introduction

In this page you can find the example usage for android.content.res TypedArray getResourceId.

Prototype

@AnyRes
public int getResourceId(@StyleableRes int index, int defValue) 

Source Link

Document

Retrieves the resource identifier for the attribute at index.

Usage

From source file:com.example.mr_zyl.project.pro.base.view.MyFragmentTabHost.java

private void initMyFragmentTabHost(Context context, AttributeSet attrs) {
    TypedArray a = context.obtainStyledAttributes(attrs, new int[] { android.R.attr.inflatedId }, 0, 0);
    mContainerId = a.getResourceId(0, 0);
    a.recycle();//  w  w  w  .j  a va  2  s  . com

    super.setOnTabChangedListener(this);
}

From source file:android.support.v13.app.FragmentTabHost.java

private void initFragmentTabHost(Context context, AttributeSet attrs) {
    TypedArray a = context.obtainStyledAttributes(attrs, new int[] { android.R.attr.inflatedId }, 0, 0);
    mContainerId = a.getResourceId(0, 0);
    a.recycle();/* w  w  w  .ja  v a  2  s.  c  o m*/

    super.setOnTabChangedListener(this);

    // If owner hasn't made its own view hierarchy, then as a convenience
    // we will construct a standard one here.
    if (findViewById(android.R.id.tabs) == null) {
        LinearLayout ll = new LinearLayout(context);
        ll.setOrientation(LinearLayout.VERTICAL);
        addView(ll, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
                ViewGroup.LayoutParams.FILL_PARENT));

        TabWidget tw = new TabWidget(context);
        tw.setId(android.R.id.tabs);
        tw.setOrientation(TabWidget.HORIZONTAL);
        ll.addView(tw, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT, 0));

        FrameLayout fl = new FrameLayout(context);
        fl.setId(android.R.id.tabcontent);
        ll.addView(fl, new LinearLayout.LayoutParams(0, 0, 0));

        mRealTabContent = fl = new FrameLayout(context);
        mRealTabContent.setId(mContainerId);
        ll.addView(fl, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, 0, 1));
    }
}

From source file:com.abcs.haiwaigou.yyg.view.ReadMoreTextView.java

public ReadMoreTextView(Context context, AttributeSet attrs) {
    super(context, attrs);
    TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.ReadMoreTextView);
    this.trimLength = typedArray.getInt(R.styleable.ReadMoreTextView_trimLength, DEFAULT_TRIM_LENGTH);
    int resourceIdTrimCollapsedText = typedArray.getResourceId(R.styleable.ReadMoreTextView_trimCollapsedText,
            R.string.read_more);/*from w w w . j a  v  a  2 s  . co  m*/
    int resourceIdTrimExpandedText = typedArray.getResourceId(R.styleable.ReadMoreTextView_trimExpandedText,
            R.string.read_less);
    this.trimCollapsedText = getResources().getString(resourceIdTrimCollapsedText);
    this.trimExpandedText = getResources().getString(resourceIdTrimExpandedText);
    this.trimLines = typedArray.getInt(R.styleable.ReadMoreTextView_trimLines, DEFAULT_TRIM_LINES);
    this.colorClickableText = typedArray.getColor(R.styleable.ReadMoreTextView_colorClickableText,
            ContextCompat.getColor(context, R.color.tljr_statusbarcolor));
    this.showTrimExpandedText = typedArray.getBoolean(R.styleable.ReadMoreTextView_showTrimExpandedText,
            DEFAULT_SHOW_TRIM_EXPANDED_TEXT);
    this.trimMode = typedArray.getInt(R.styleable.ReadMoreTextView_trimMode, TRIM_MODE_LINES);
    typedArray.recycle();
    viewMoreSpan = new ReadMoreClickableSpan();
    onGlobalLayoutLineEndIndex();
    setText();
}

From source file:cn.bproject.neteasynews.widget.FragmentTabHost.java

private void initFragmentTabHost(Context context, AttributeSet attrs) {
    TypedArray a = context.obtainStyledAttributes(attrs, new int[] { android.R.attr.inflatedId }, 0, 0);
    mContainerId = a.getResourceId(0, 0);
    a.recycle();/*from w w w.  j  ava 2  s  .c  o  m*/

    super.setOnTabChangedListener(this);
}

From source file:com.borjabravo.readmoretextview.ReadMoreTextView.java

public ReadMoreTextView(Context context, AttributeSet attrs) {
    super(context, attrs);
    TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.ReadMoreTextView);
    this.trimLength = typedArray.getInt(R.styleable.ReadMoreTextView_trimLength, DEFAULT_TRIM_LENGTH);
    int resourceIdTrimCollapsedText = typedArray.getResourceId(R.styleable.ReadMoreTextView_trimCollapsedText,
            R.string.read_more);/*  w  ww.  ja  v  a 2 s .co m*/
    int resourceIdTrimExpandedText = typedArray.getResourceId(R.styleable.ReadMoreTextView_trimExpandedText,
            R.string.read_less);
    this.trimCollapsedText = getResources().getString(resourceIdTrimCollapsedText);
    this.trimExpandedText = getResources().getString(resourceIdTrimExpandedText);
    this.trimLines = typedArray.getInt(R.styleable.ReadMoreTextView_trimLines, DEFAULT_TRIM_LINES);
    this.colorClickableText = typedArray.getColor(R.styleable.ReadMoreTextView_colorClickableText,
            ContextCompat.getColor(context, R.color.accent));
    this.showTrimExpandedText = typedArray.getBoolean(R.styleable.ReadMoreTextView_showTrimExpandedText,
            DEFAULT_SHOW_TRIM_EXPANDED_TEXT);
    this.trimMode = typedArray.getInt(R.styleable.ReadMoreTextView_trimMode, TRIM_MODE_LINES);
    typedArray.recycle();
    viewMoreSpan = new ReadMoreClickableSpan();
    onGlobalLayoutLineEndIndex();
    setText();
}

From source file:com.finalmapservices.view.FragmentTabHost.java

private void initFragmentTabHost(Context context, AttributeSet attrs) {

    if (isInEditMode()) {
        return;/*from  w ww  . jav  a  2  s  .com*/
    }
    TypedArray a = context.obtainStyledAttributes(attrs, new int[] { android.R.attr.inflatedId }, 0, 0);
    mContainerId = a.getResourceId(0, 0);
    a.recycle();

    super.setOnTabChangedListener(this);
}

From source file:com.anlddev.customwidget.widget.AFragmentTabHost.java

private void initFragmentTabHost(Context context, AttributeSet attrs) {
    final TypedArray a = context.obtainStyledAttributes(attrs, new int[] { android.R.attr.inflatedId }, 0, 0);
    mContainerId = a.getResourceId(0, 0);
    a.recycle();/*from  w w  w  . j  a  v  a 2s  .com*/

    super.setOnTabChangedListener(this);
}

From source file:com.jana.android.ui.support.FragmentTabHost.java

private void initFragmentTabHost(Context context, AttributeSet attrs) {
    TypedArray a = context.obtainStyledAttributes(attrs, new int[] { android.R.attr.inflatedId }, 0, 0);
    mContainerId = a.getResourceId(0, 0);
    a.recycle();//from   w  ww  . ja v a2s.  c  om

    super.setOnTabChangedListener(this);

    // If owner hasn't made its own view hierarchy, then as a convenience
    // we will construct a standard one here.
    /*if (findViewById(android.R.id.tabs) == null) {
    LinearLayout ll = new LinearLayout(context);
    ll.setOrientation(LinearLayout.VERTICAL);
    addView(ll, new FrameLayout.LayoutParams(
            ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.FILL_PARENT));
            
    TabWidget tw = new TabWidget(context);
    tw.setId(android.R.id.tabs);
    tw.setOrientation(TabWidget.HORIZONTAL);
    ll.addView(tw, new LinearLayout.LayoutParams(
            ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT, 0));
            
    FrameLayout fl = new FrameLayout(context);
    fl.setId(android.R.id.tabcontent);
    ll.addView(fl, new LinearLayout.LayoutParams(0, 0, 0));
            
    mRealTabContent = fl = new FrameLayout(context);
    mRealTabContent.setId(mContainerId);
    ll.addView(fl, new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.FILL_PARENT, 0, 1));
    }*/
}

From source file:com.facebook.react.views.toolbar.ReactToolbarManager.java

private int[] getDefaultContentInsets(Context context) {
    Resources.Theme theme = context.getTheme();
    TypedArray toolbarStyle = null;
    TypedArray contentInsets = null;//  ww w  .ja  v a  2  s  .c  o  m

    try {
        toolbarStyle = theme.obtainStyledAttributes(new int[] { getIdentifier(context, "toolbarStyle") });

        int toolbarStyleResId = toolbarStyle.getResourceId(0, 0);

        contentInsets = theme.obtainStyledAttributes(toolbarStyleResId, new int[] {
                getIdentifier(context, "contentInsetStart"), getIdentifier(context, "contentInsetEnd"), });

        int contentInsetStart = contentInsets.getDimensionPixelSize(0, 0);
        int contentInsetEnd = contentInsets.getDimensionPixelSize(1, 0);

        return new int[] { contentInsetStart, contentInsetEnd };
    } finally {
        recycleQuietly(toolbarStyle);
        recycleQuietly(contentInsets);
    }

}

From source file:com.iutiao.sdk.views.PasswordEditText.java

public void initFields(AttributeSet attrs, int defStyleAttr) {
    if (attrs != null) {
        // ??//from   w  w w. ja  v a2  s .  c  o m
        TypedArray styles = getContext().getTheme().obtainStyledAttributes(attrs, R.styleable.PasswordEditText,
                defStyleAttr, 0);
        try {
            // ??, Icon
            mShowPwdIcon = styles.getResourceId(R.styleable.PasswordEditText_pet_iconShow, mShowPwdIcon);
            mHidePwdIcon = styles.getResourceId(R.styleable.PasswordEditText_pet_iconHide, mHidePwdIcon);
        } finally {
            styles.recycle();
        }
    }

    // ??
    setInputType(EditorInfo.TYPE_CLASS_TEXT | EditorInfo.TYPE_TEXT_VARIATION_PASSWORD);

    addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {

        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            if (s.length() > 0) {
                // 
                showPasswordVisibilityIndicator(true);
            } else {
                mIsShowPwdIcon = false;
                restorePasswordIconVisibility(mIsShowPwdIcon);
                showPasswordVisibilityIndicator(false); // ??
            }
        }

        @Override
        public void afterTextChanged(Editable s) {

        }
    });
}