View getId - 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 getId method.

This code example shows how to use the following methods:getContentDescription, getHeight, getId, getLocationOnScreen, getWidth
 
	@SuppressWarnings({ "rawtypes", "unchecked" }) 
	public static Object extractDataFromView(View v) {		
		 
		Map data = new HashMap();
		data.put("class", v.getClass().getName());		
		data.put("description", v.toString());
		CharSequence description = v.getContentDescription();
		data.put("contentDescription", description != null ? description.toString() : null);
		data.put("enabled", v.isEnabled());
		String id = null;
		try { 
			id = InstrumentationBackend.solo.getCurrentActivity()
					.getResources().getResourceEntryName(v.getId());
		} catch (Resources.NotFoundException e) {
			System.out.println("Resource not found for " + v.getId()
					+ ". Moving on."); 
		} 
		data.put("id", id);
 

8
CodeRank
This code example shows how to use the following methods:getId, setId, setLayoutParams
RelativeLayout listItemLayout = new RelativeLayout( activity );
		listItemLayout.setPadding( 5, 5, 5, 5 );
		 
		TextView label = new TextView( activity );
		ImageView icon = new ImageView( activity );
		icon.setId( 100 );
		 
		RelativeLayout.LayoutParams labelParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT );
		labelParams.addRule( RelativeLayout.ALIGN_PARENT_RIGHT );
		labelParams.addRule( RelativeLayout.RIGHT_OF, icon.getId( ) );
		labelParams.addRule( RelativeLayout.CENTER_VERTICAL );
		labelParams.setMargins( 5, 0, 0, 5 );
		label.setLayoutParams( labelParams );
		 
		label.setTextSize( 15.0f );
		 
		RelativeLayout.LayoutParams iconParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT );
		iconParams.addRule( RelativeLayout.ALIGN_PARENT_LEFT );
		iconParams.addRule( RelativeLayout.CENTER_VERTICAL );

8
CodeRank
This code example shows how to use the following methods:getContext, getId, getVisibility
    out.print("<" + realView.getClass().getSimpleName());
    dumpAttributes(out);
  } 
 
  protected void dumpAttributes(PrintStream out) {
    if (realView.getId() > 0) {
      dumpAttribute(out, "id", shadowOf(realView.getContext()).getResourceLoader().getNameForId(realView.getId()));
    } 
 
    switch (realView.getVisibility()) {
      case View.VISIBLE:
        break; 
      case View.INVISIBLE:
        dumpAttribute(out, "visibility", "INVISIBLE");
        break; 
      case View.GONE:
        dumpAttribute(out, "visibility", "GONE");
        break; 
    } 
  } 
8
CodeRank
This code example shows how to use the following methods:getId
  } 
 
 
 
private AndroidNativeElement newAndroidElement(View view) {
    Preconditions.checkNotNull(view);
    if (knownElements.hasElement(new Long(view.getId()))) {
      AndroidNativeElement element =
          (AndroidNativeElement) knownElements.get(new Long(view.getId()));
      if (element.getView().equals(view)) {
        return element;
      } 
    } 
    AndroidNativeElement e = new AndroidNativeElement(view, serverInstrumentation, knownElements);
    knownElements.add(e);
    return e;
  } 
 
protected List<View> getTopLevelViews() {
    List<View> views = new ArrayList<View>();
7
CodeRank
This code example shows how to use the following methods:getId, setId, setLayoutParams, addView
            } 
        }; 
        this.etColor.setFilters(filters);
        this.etColor.addTextChangedListener(this);
 
        LinearLayout ll1 = new LinearLayout(getContext());
        ll1.setId(generateViewId());
        RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(
                android.view.ViewGroup.LayoutParams.MATCH_PARENT,
                android.view.ViewGroup.LayoutParams.WRAP_CONTENT);
        lp.setMargins(dlgMarging, 0, dlgMarging, 0);
        lp.addRule(RelativeLayout.ALIGN_PARENT_TOP);
        ll1.setLayoutParams(lp);
        ll1.addView(this.tvColorLabel);
        ll1.addView(this.etColor);
        parent.addView(ll1);
 
        return ll1.getId();
    } 
 

7
CodeRank
This code example shows how to use the following methods:getId, setId, setLayoutParams, setGravity, setText
				RelativeLayout.LayoutParams.WRAP_CONTENT,
				RelativeLayout.LayoutParams.WRAP_CONTENT);
		titleparams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
		titleparams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
 
		final TextView title = new TextView(getContext());
		title.setText(getTitle());
		title.setTextSize(24);
		title.setTextColor(Color.WHITE);
		title.setTypeface(Typeface.DEFAULT, Typeface.NORMAL);
		title.setGravity(Gravity.LEFT);
		title.setLayoutParams(titleparams);
		title.setId(TITLE_ID);
		 
		 
		//setup description 
		final RelativeLayout.LayoutParams descriptionparams = new RelativeLayout.LayoutParams(
				RelativeLayout.LayoutParams.WRAP_CONTENT,
				RelativeLayout.LayoutParams.WRAP_CONTENT);
		descriptionparams.addRule(RelativeLayout.BELOW, title.getId());

7
CodeRank
This code example shows how to use the following methods:getId, setId
    } 
 
    public MenuItem setActionView(View view) {
        mActionView = view;
        mActionProvider = null;
        if (view != null && view.getId() == View.NO_ID && mId > 0) {
            view.setId(mId);
        } 
        mMenu.onItemActionRequestChanged(this);
        return this;
    } 
 
    public MenuItem setActionView(int resId) {
        final Context context = mMenu.getContext();
        final LayoutInflater inflater = LayoutInflater.from(context);
        setActionView(inflater.inflate(resId, new LinearLayout(context), false));
        return this;
    } 
 
    public View getActionView() {
7
CodeRank
This code example shows how to use the following methods:getId
     */ 
    @Override 
    public void addView(View child, int index, ViewGroup.LayoutParams params) {
        super.addView(child, index, params);
         
        int childId = child.getId();
        if (childId == CHRONOMETER_ID && child instanceof Chronometer) {
            mChronometer = (Chronometer) child;
            mChronometer.setOnChronometerTickListener(this);
             
            // Check if Chronometer should move with with ProgressBar  
            mChronometerFollow = (params.width == ViewGroup.LayoutParams.WRAP_CONTENT);
            mChronometerGravity = (mChronometer.getGravity() &
                    Gravity.RELATIVE_HORIZONTAL_GRAVITY_MASK);
             
        } else if (childId == PROGRESSBAR_ID && child instanceof ProgressBar) {
            mProgressBar = (ProgressBar) child;
        } 
    } 
 
7
CodeRank
This code example shows how to use the following methods:getId
        super(Robolectric.application, false); 
    } 
 
    @Override 
    public void loadImage(String imageUrl, ImageView imageView) {
        loadedImages.add(imageView.getId());
    } 
 
    @Override 
    public void loadImage(String imageUrl, ImageView imageView, RemoteImageLoaderHandler handler) {
        loadedImages.add(imageView.getId());
    } 
 
    public boolean isLoadImageCalled(RemoteImageView view) {
        return loadedImages.contains(view.getId());
    } 
} 
7
CodeRank
This code example shows how to use the following methods:getId
        } else { 
            fragment = getItem(position);
            if (DEBUG) Log.v(TAG, "Adding item #" + itemId + ": f=" + fragment);
//            mCurTransaction.add(container.getId(), fragment, 
//                    makeFragmentName(container.getId(), itemId)); 
            mCurTransaction.add(container.getId(), fragment,
                    getTag(position));
        } 
        if (fragment != mCurrentPrimaryItem) {
            fragment.setMenuVisibility(false);
            fragment.setUserVisibleHint(false);
        } 
 
        return fragment;
    } 
 
    @Override 
    public void destroyItem(ViewGroup container, int position, Object object) {
        if (mCurTransaction == null) {
            mCurTransaction = mFragmentManager.beginTransaction();
6
CodeRank

Related View getId Questions & Answers:

Other View getId Examples

24:	
25:	  public void onClicked(View view) {
26:	    String text = view.getId() == R.id.view1 ? "Background" : "Foreground";
27:	    Toast.makeText(this, text, Toast.LENGTH_SHORT).show();
28:	  }

Read More

234:		@Override
235:		public void onClick(View v) {
236:			switch (v.getId()) {
237:			case R.id.btn_sign_in:
238:				// Signin button clicked

Read More

80:		@Override
81:		public void onClick(View v) {
82:			switch (v.getId()) {
83:			case R.id.btn_sign_in:
84:				// Signin button clicked

Read More

4:	    
5:	    // Check which checkbox was clicked
6:	    switch(view.getId()) {
7:	        case R.id.checkbox_meat:
8:	            if (checked)

Read More

4:	    
5:	    // Check which radio button was clicked
6:	    switch(view.getId()) {
7:	        case R.id.radio_pirates:
8:	            if (checked)

Read More

getId Method Overview
Returns this view's identifier.
See Code Examples for other Android View Methods: