View findViewById - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for View findViewById method.

This code example shows how to use the following methods:findViewById, isFocused, requestFocus, setOnFocusChangeListener
    /** 
     * @param editViewId must be EditView 
     */ 
    public void requestFocusAndShowKeyboard(int editViewId) {
        // Set Focus to password View. 
        final View viewToBeFocused = mView.findViewById(editViewId);
        if (viewToBeFocused == null) {
            Log.w(TAG, "password field to be focused not found.");
        } else if (!(viewToBeFocused instanceof EditText)) {
            Log.w(TAG, "password field is not EditText");
        } else { 
            if (viewToBeFocused.isFocused()) {
                Log.i(TAG, "Already focused");
                if (!mInputMethodManager.showSoftInput(viewToBeFocused, 0)) {
                    Log.w(TAG, "Failed to show SoftInput");
                } 
            } else { 
                // After acquiring the focus, we show software keyboard. 
                viewToBeFocused.setOnFocusChangeListener(this);
                final boolean requestFocusResult = viewToBeFocused.requestFocus();

8
CodeRank
This code example shows how to use the following methods:findViewById, setTag
    public View doGetView(int position, View convertView, ViewGroup parent, boolean dropdown) {
        ViewHolder holder;
        if (convertView == null) {
            convertView = mInflater.inflate(R.layout.user_list_item, null);
            holder = new ViewHolder();
            holder.gravatar = (ImageView) convertView.findViewById(R.id.iv_user_gravatar);
            holder.login = (TextView) convertView.findViewById(R.id.tv_user_login);
            convertView.setTag(holder);
        } else { 
            holder = (ViewHolder) convertView.getTag();
        } 
 
        final User user = getItem(position);
 
        final String login = user.getLogin();
        final String type = user.getType();
 
        final AQuery aq = new AQuery(convertView);
        aq.id(holder.gravatar)
                .image(user.getAvatarUrl(), true, true, 200, R.drawable.gravatar, null,

8
CodeRank
This code example shows how to use the following methods:findViewById
            throw new IllegalStateException("Content view not yet created");
        } 
        if (root instanceof ExpandableListView) {
            mList = (ExpandableListView)root;
        } else { 
            mStandardEmptyView = (TextView)root.findViewById(INTERNAL_EMPTY_ID);
            if (mStandardEmptyView == null) {
                mEmptyView = root.findViewById(android.R.id.empty);
            } 
            View rawListView = root.findViewById(android.R.id.list);
            if (!(rawListView instanceof ExpandableListView)) {
                if (rawListView == null) {
                    throw new RuntimeException(
                            "Your content must have a ExpandableListView whose id attribute is " + 
                            "'android.R.id.list'"); 
                } 
                throw new RuntimeException(
                        "Content has view with id attribute 'android.R.id.list' " 
                        + "that is not a ExpandableListView class"); 
            } 
8
CodeRank
This code example shows how to use the following methods:findViewById, getTag, setTag
This code example shows how to use the following methods:findViewById, setVisibility
        setupView(position, v);
        return v;
    } 
 
    private void setupView(int position, View view) {
        ImageView iv = (ImageView) view.findViewById(mImageId);
        TextView tv = (TextView) view.findViewById(mTextId);
        View separator = view.findViewById(mSeparatorId);
 
        if (!isEnabled(position)) {
            if (iv != null) {
                iv.setVisibility(View.GONE);
            } 
            if (tv != null) {
                tv.setVisibility(View.GONE);
            } 
            if (separator != null) {
                separator.setVisibility(View.VISIBLE);
            } 
        } else { 

7
CodeRank
This code example shows how to use the following methods:findViewById
            view = convertView;
        } 
        try { 
            if (view != null) {
                if (mFieldId > 0) {
                    text = (TextView) view.findViewById(mFieldId);
                } else { 
                    text = (TextView) view.findViewById(android.R.id.text1);
                } 
                if (text == null && view instanceof TextView) {
                    text = (TextView) view;
                } 
            } 
            if (text == null) {
                throw new NullPointerException();
            } 
        } catch (RuntimeException e) {
            Log.e("ArrayAdapter",
                    "You must supply a resource ID for a TextView"); 
            throw new IllegalStateException(
7
CodeRank
This code example shows how to use the following methods:findViewById, setTag
 
        if (v == null) {
            LayoutInflater vi = (LayoutInflater) LayoutInflater.from(mContext);
            v = vi.inflate(R.layout.row_simple_3, null);
            viewHolder = new ViewHolder();
            viewHolder.tvTitle = (TextView) v.findViewById(R.id.tv_title);
            viewHolder.tvDesc = (TextView) v.findViewById(R.id.tv_desc);
            viewHolder.tvExtra = (TextView) v.findViewById(R.id.tv_extra);
             
            v.setTag(viewHolder);
        } 
        else { 
            viewHolder = (ViewHolder) v.getTag();
        } 
 
        final Trend trend = mObjects.get(position);
        if (trend != null) {
            viewHolder.tvTitle.setText(trend.getTitle());
            viewHolder.tvDesc.setText(trend.getDescription());
            viewHolder.tvExtra.setVisibility(View.GONE);
7
CodeRank
This code example shows how to use the following methods:findViewById, getBottom, getLeft, getRight
									View item = (View) getChildAt(itemnum - getFirstVisiblePosition());
									 
									if (isDraggableRow(item)) {
										mDragPoint = y - item.getTop();
										mCoordOffset = ((int)ev.getRawY()) - y;
										View dragger = item.findViewById(grabberId);
										Rect r = mTempRect;
//										dragger.getDrawingRect(r); 
									 
										r.left=dragger.getLeft();
										r.right=dragger.getRight();
										r.top=dragger.getTop();
										r.bottom=dragger.getBottom();									
										 
										if ((r.left<x) && (x<r.right)) {
												item.setDrawingCacheEnabled(true);
												// Create a copy of the drawing cache so that it does not get recycled 
												// by the framework when the list tries to clean up memory 
												Bitmap bitmap = Bitmap.createBitmap(item.getDrawingCache());
												item.setDrawingCacheEnabled(false);

7
CodeRank
This code example shows how to use the following methods:findViewById, getTag, setTag
 
        //Retrieve data holder 
        final DataHolder dataHolder = this.mData[position];
 
        //Retrieve the view holder 
        ViewHolder viewHolder = (ViewHolder)v.getTag();
 
        //Set the data 
        viewHolder.mIvIcon.setImageDrawable(dataHolder.mDwIcon);
        viewHolder.mTvName.setText(dataHolder.mName);
        viewHolder.mTvDirectory.setText(dataHolder.mDirectory);
        viewHolder.mTvPosition.setText(dataHolder.mPosition);
 
        //Return the view 
        return v;
    } 
 
    /** 
     * Method that should be invoked when the theme of the app was changed 
     */ 
7
CodeRank
This code example shows how to use the following methods:findViewById
    public WidgetContainer(Context context, AttributeSet attrs, int defStyleAttr) {
        this(context, attrs);
    } 
 
    public void setTitle(CharSequence title) {
        TextView textView = (TextView) titleView
                .findViewById(android.R.id.text1);
        if (textView != null) {
            textView.setText(title);
        } 
    } 
 
    public void setTitle(int title) {
        setTitle(getResources().getText(title));
    } 
} 
7
CodeRank

Related View findViewById Questions & Answers:

Other View findViewById Examples

47:	        }
48:	         
49:	        ImageView imgIcon = (ImageView) convertView.findViewById(R.id.icon);
50:	        TextView txtTitle = (TextView) convertView.findViewById(R.id.title);
51:	        TextView txtCount = (TextView) convertView.findViewById(R.id.counter);
-
48:	         
49:	        ImageView imgIcon = (ImageView) convertView.findViewById(R.id.icon);
50:	        TextView txtTitle = (TextView) convertView.findViewById(R.id.title);
51:	        TextView txtCount = (TextView) convertView.findViewById(R.id.counter);
52:	         
-
49:	        ImageView imgIcon = (ImageView) convertView.findViewById(R.id.icon);
50:	        TextView txtTitle = (TextView) convertView.findViewById(R.id.title);
51:	        TextView txtCount = (TextView) convertView.findViewById(R.id.counter);
52:	         
53:	        imgIcon.setImageResource(navDrawerItems.get(position).getIcon());

Read More

50:	        }
51:	        
52:	        imgIcon = (ImageView) convertView.findViewById(R.id.imgIcon);
53:	        txtTitle = (TextView) convertView.findViewById(R.id.txtTitle);
54:	        
-
51:	        
52:	        imgIcon = (ImageView) convertView.findViewById(R.id.imgIcon);
53:	        txtTitle = (TextView) convertView.findViewById(R.id.txtTitle);
54:	        
55:	        imgIcon.setImageResource(spinnerNavItem.get(position).getIcon());
-
68:	        }
69:	        
70:	        imgIcon = (ImageView) convertView.findViewById(R.id.imgIcon);
71:	        txtTitle = (TextView) convertView.findViewById(R.id.txtTitle);
72:	        
-
69:	        
70:	        imgIcon = (ImageView) convertView.findViewById(R.id.imgIcon);
71:	        txtTitle = (TextView) convertView.findViewById(R.id.txtTitle);
72:	        
73:	        imgIcon.setImageResource(spinnerNavItem.get(position).getIcon());

Read More

49:	
50:			TextView txtListChild = (TextView) convertView
51:					.findViewById(R.id.lblListItem);
52:	
53:			txtListChild.setText(childText);
-
87:	
88:			TextView lblListHeader = (TextView) convertView
89:					.findViewById(R.id.lblListHeader);
90:			lblListHeader.setTypeface(null, Typeface.BOLD);
91:			lblListHeader.setText(headerTitle);

Read More

3:	    ...
4:	    View v = inflater.inflate(R.layout.main, container, false);
5:	    mAdStatus = (TextView) v.findViewById(R.id.status);
6:	    mAdView = (AdView) v.findViewById(R.id.ad);
7:	    mAdView.setAdListener(new MyAdListener());
-
4:	    View v = inflater.inflate(R.layout.main, container, false);
5:	    mAdStatus = (TextView) v.findViewById(R.id.status);
6:	    mAdView = (AdView) v.findViewById(R.id.ad);
7:	    mAdView.setAdListener(new MyAdListener());
8:

Read More

findViewById Method Overview
Look for a child view with the given id.
See Code Examples for other Android View Methods: