Android View - top ranked examples from Open Source projects

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

This code example shows how to use the following methods: setBackgroundColor, setLayoutParams, setVisibility, addView, addContentView
This code example shows how to use the following methods: setId, setLayoutParams, setOrientation
        void setContentToFragment(T fragment) {
            if (fragment == null) {
                fragment = createFragment();
            } 
 
            LinearLayout layout = new LinearLayout(this);
            layout.setOrientation(LinearLayout.VERTICAL);
            layout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT,
                    LinearLayout.LayoutParams.FILL_PARENT));
            layout.setId(FRAGMENT_ID);
 
            getSupportFragmentManager().beginTransaction() 
                    .add(FRAGMENT_ID, fragment)
                    .commit(); 
 
            fragmentId = FRAGMENT_ID;
 
            setContentView(layout);
        } 
 
Full Snippet Info
9
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: setBackgroundColor, setLayoutParams, addView, setOrientation
        		ViewGroup.LayoutParams.FILL_PARENT, 0.0F);
          
        LinearLayout.LayoutParams webviewParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
        		ViewGroup.LayoutParams.FILL_PARENT, 1.0F);
         
        root = new LinearLayout(this);
        root.setOrientation(LinearLayout.VERTICAL);
        root.setBackgroundColor(Color.BLACK);
        root.setLayoutParams(containerParams);
                 
        appView = new WebView(this);
        appView.setLayoutParams(webviewParams);
         
        WebViewReflect.checkCompatibility(); 
         
        /* This changes the setWebChromeClient to log alerts to LogCat!  Important for Javascript Debugging */        
        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.ECLAIR)
        	appView.setWebChromeClient(new EclairClient(this));        	
        else 
        	appView.setWebChromeClient(new GapClient(this));

9
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: getVisibility, setImageDrawable, setVisibility
        if (mIconView == null) {
            insertIconView(); 
        } 
 
        if (icon != null || mPreserveIconSpacing) {
            mIconView.setImageDrawable(showIcon ? icon : null);
 
            if (mIconView.getVisibility() != VISIBLE) {
                mIconView.setVisibility(VISIBLE);
            } 
        } else { 
            mIconView.setVisibility(GONE);
        } 
    } 
 
    @Override 
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        if (mIconView != null && mPreserveIconSpacing) {
            // Enforce minimum icon spacing 
            ViewGroup.LayoutParams lp = getLayoutParams();
Full Snippet Info
9
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: measure, setBackground, layout, draw, dispatchOnPreDraw
                    drawableResource.getResourceType() != ResourceType.DRAWABLE) {
                return Status.ERROR_NOT_A_DRAWABLE.createResult(); 
            } 
 
            // create a simple FrameLayout 
            FrameLayout content = new FrameLayout(context);
 
            // get the actual Drawable object to draw 
            Drawable d = ResourceHelper.getDrawable(drawableResource, context);
            content.setBackground(d);
 
            // set the AttachInfo on the root view. 
            AttachInfo_Accessor.setAttachInfo(content);
 
 
            // measure 
            int w = hardwareConfig.getScreenWidth();
            int h = hardwareConfig.getScreenHeight();
            int w_spec = MeasureSpec.makeMeasureSpec(w, MeasureSpec.EXACTLY);
            int h_spec = MeasureSpec.makeMeasureSpec(h, MeasureSpec.EXACTLY);

9
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: setTag, addView, setOrientation
                      ViewGroup parent) {
    ViewWrapper wrap=null;
    View row=convertView;
                             
    if (convertView==null) {
      LinearLayout layout=new LinearLayout(ctxt);
      RatingBar rate=new RatingBar(ctxt);
       
      rate.setNumStars(3);
      rate.setStepSize(1.0f);
       
      View guts=delegate.getView(position, null, parent);
     
      layout.setOrientation(LinearLayout.HORIZONTAL); 
           
      rate.setLayoutParams(new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.WRAP_CONTENT,
            LinearLayout.LayoutParams.FILL_PARENT));
      guts.setLayoutParams(new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.FILL_PARENT,

8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: getLayoutParams, getWidth, getMax, getProgress, setProgress
            mChronometer.stop();
        } 
 
        // Update the ProgressBar status 
        int remaining = (int) (mDurationBase - now);
        mProgressBar.setProgress(mDuration - remaining);
         
        // Move the Chronometer if gravity is set correctly 
        if (mChronometerFollow) {
            RelativeLayout.LayoutParams params;
             
            // Calculate estimate of ProgressBar leading edge position 
            params = (RelativeLayout.LayoutParams) mProgressBar.getLayoutParams();
            int contentWidth = mProgressBar.getWidth() - (params.leftMargin + params.rightMargin);
            int leadingEdge = ((contentWidth * mProgressBar.getProgress()) /
                    mProgressBar.getMax()) + params.leftMargin;
             
            // Calculate any adjustment based on gravity 
            int adjustLeft = 0;
            int textWidth = mChronometer.getWidth();
            if (mChronometerGravity == Gravity.END) {
Full Snippet Info
9
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: setFocusable, setFocusableInTouchMode, setLayoutParams, setOnKeyListener, getImeOptions
This code example shows how to use the following methods: setMinimumHeight, setMinimumWidth
                mContext = context;
            } 
 
            @Override 
            public View createTabContent(String tag) {
                View v = new View(mContext);
                v.setMinimumWidth(0);
                v.setMinimumHeight(0);
                return v;
            } 
        } 
 
        public TabManager(FragmentActivity activity, TabHost tabHost, int containerId) {
            mActivity = activity;
            mTabHost = tabHost;
            mContainerId = containerId;
            mTabHost.setOnTabChangedListener(this);
        } 
 
        public void addTab(TabHost.TabSpec tabSpec, Class<?> clss, Bundle args) {
Full Snippet Info
9
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: getScrollX, getScrollY, getLayout, getTotalPaddingLeft, getTotalPaddingTop
 
		if (action == MotionEvent.ACTION_UP) {
			int x = (int) event.getX();
			int y = (int) event.getY();
 
			x -= widget.getTotalPaddingLeft();
			y -= widget.getTotalPaddingTop();
 
			x += widget.getScrollX();
			y += widget.getScrollY();
 
			Layout layout = widget.getLayout();
			int line = layout.getLineForVertical(y);
			int off = layout.getOffsetForHorizontal(line, x);
 
			ClickableSpan[] links = buffer.getSpans(off, off,
					ClickableSpan.class);
 
			if (links.length != 0 && links[0] instanceof URLSpan) {
				HashMap args = new HashMap();
Full Snippet Info
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java

Related Android View Questions & Answers:

Other Android View Examples

21:	  File audiofile = null;
22:	  private static final String TAG = "SoundRecordingActivity";
23:	  private View startButton;
24:	  private View stopButton;
25:	
-
22:	  private static final String TAG = "SoundRecordingActivity";
23:	  private View startButton;
24:	  private View stopButton;
25:	
26:	  @Override
-
32:	  }
33:	
34:	  public void startRecording(View view) throws IOException {
35:	
36:	    startButton.setEnabled(false);
-
53:	  }
54:	
55:	  public void stopRecording(View view) {
56:	    startButton.setEnabled(true);
57:	    stopButton.setEnabled(false);

Read More

15:	    setContentView(R.layout.main);
16:	    // define the contextual action mode
17:	    View view = findViewById(R.id.myView);
18:	    view.setOnLongClickListener(new View.OnLongClickListener() {
19:	      // called when the user long-clicks on someView
-
18:	    view.setOnLongClickListener(new View.OnLongClickListener() {
19:	      // called when the user long-clicks on someView
20:	      public boolean onLongClick(View view) {
21:	        if (mActionMode != null) {
22:	          return false;

Read More

23:	  }
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();

Read More

5:				@Override
6:				public void onClick(View arg0) {
7:					if(isShuffle){
8:						isShuffle = false;
9:						Toast.makeText(getApplicationContext(), "Shuffle is OFF", Toast.LENGTH_SHORT).show();

Read More

5:				@Override
6:				public void onClick(View arg0) {
7:					if(isRepeat){
8:						isRepeat = false;
9:						Toast.makeText(getApplicationContext(), "Repeat is OFF", Toast.LENGTH_SHORT).show();

Read More

10:	
11:		@Override
12:		public View onCreateView(LayoutInflater inflater, ViewGroup container,
13:				Bundle savedInstanceState) {
14:	
-
13:				Bundle savedInstanceState) {
14:	
15:			View rootView = inflater.inflate(R.layout.fragment_movies, container, false);
16:			
17:			return rootView;

Read More

1:	@MediumTest
2:	public void testInfoTextView_layout() {
3:	    final View decorView = mClickFunActivity.getWindow().getDecorView();
4:	    ViewAsserts.assertOnScreen(decorView, mInfoTextView);
5:	    assertTrue(View.GONE == mInfoTextView.getVisibility());

Read More

1:	someView.setOnLongClickListener(new View.OnLongClickListener() {
2:	    // Called when the user long-clicks on someView
3:	    public boolean onLongClick(View view) {
4:	        if (mActionMode != null) {
5:	            return false;

Read More

1:	@MediumTest
2:	public void testClickMeButton_layout() {
3:	    final View decorView = mClickFunActivity.getWindow().getDecorView();
4:	
5:	    ViewAsserts.assertOnScreen(decorView, mClickMeButton);

Read More

See Code Examples for Android View Methods: