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
Stop searching for code, let great code find you!  Add Codota to your java IDE
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
Stop searching for code, let great code find you!  Add Codota to your java IDE
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
Stop searching for code, let great code find you!  Add Codota to your java IDE
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
Stop searching for code, let great code find you!  Add Codota to your java IDE

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: