w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
How to draw views using Canvas Android?
The problem with this relativeLayout.addView(draw); setContentView(draw); You can add a view to only one layout at a time. You can't add the same View to multiple ViewGroups (Layouts). The code above add the 'draw' View as a child of the 'relativeLayout' when sets it as the content View (for whatever class 'this.' is). You can add the View with either: relativeLayout.addView(draw); or setContentView(draw);

Categories : Android

Custom views in android
Edit It turns out the the size of the canvas provided to onDraw isn't guaranteed to be the same size as the actual viewed size of the View. It is merely guaranteed to be sufficiently large. In your case, it is too big! According to this question and answer, the key is to use the sizes returned in onSizeChanged as definitive for the current displayed size of the View. So you should retain the dimensions from onSizeChanged, and use them in onDraw to know the actual size you should draw to. ie,: childWidthMeasureSpec and childHeightMeasureSpec should become class variables which are set in onSizeChanged. In onDraw, use them instead of canvas.getWidth() and canvas.getHeight() respectively. Whilst this behaviour seems a bit odd at first glance, it allows android to lower the number of can

Categories : Android

Android Crouton library implementing Custom Views
Follow this link you may get answer Another Link His idea is to show in-app notifications (not to be confused with Android’s persistent notifications) at a fixed place of the Activity to which the notification is relevant. This way the context of the notification is always correct

Categories : Android

How to make circle drawable in Android custom canvas?
Why make a drawable? You can easily draw a circle via the canvas.drawCircle command. You can also easily make one via a Path object. Edit: If you need a drawable, try making a ShapeDrawable based off an OvalShape.

Categories : Android

Android two Canvas within single Custom View (within onDraw())
for using another Canvas u need draw a bitmap on second canvas and then draw that on canvas Bitmap bitmap ; Canvas c2 = new Canvas(bitmap); @Override public void onDraw(Canvas canvas) { canvas.drawLine(0,0,600,200,black); // Draw on Second canvas c2.drawLine(0,0,500,100,Red); // Draw second canvas (c2) to first one canvas.drawBitmap(bitmap, 0, 0, null); }

Categories : Android

Only first row's views(button) are clickable in custom list view, android
In your custom adapter constructor LayoutInflater mInflater; CustomAdapter(Context c) { mInflater = LayoutInflater.from(c); // initialize inflater in the constructor. // need not initialize everytime getView is called. } Use a View Holder http://developer.android.com/training/improving-layouts/smooth-scrolling.html static class ViewHolder { ImageButton ib; } @Override public View getView(int position, View item, ViewGroup parent) { ViewHolder holder; if(item == null){ item = mInflater.inflate(R.layout.elementos_lista_temas, null); holder = new ViewHolder(); holder.ib = (ImageButton) item.findViewById(R.id.imagebutton); item.setTag(holder); }

Categories : Android

Can MvvmCross use 3rd party Views that are defined inside of external assemblies (i.e. platform-specific Views it has no control over)?
You can do something similar to this dialog messages solution. you basically use the messenger and listen for an Authenticate message in the views for each platform to show your login UI and fire a message back when it's done. I'm using the old Azure ACS controls in a similar way (firing an message to show them and binding to events on the usercontrol for the result)

Categories : Authentication

error: No resource identifier found for attribute in custom-views from http://developer.android.com
I meet the same problem,I think your custom attributes don't belong to the right namespace.You can get the demo of customview_panda and look at custom attribute in the main.xml,you will understand. https://github.com/pandabo1985/Android_App_Prac

Categories : Android

Android - Horizontal Scrolling Views Inside Vertically Scrolling View
So for your first two views I would recommend you using HorizontalListView, then for other items, if they are always 6 squares in a row, create some simple LinearLayout with horizontal orientation and 6 inner views. As for the whole layout use ordinary ListView. There are really nothing special in using HorizontalListView inside ListView because they scroll on different axis, however in your adapter you would have to implement getItemViewType(int position) and getViewTypeCount(), because you have two different types of views in your layout, using this methods android knows what kind of views to supply for reuse in your convertView in getView(int position, View convertView, ViewGroup parent). And using this mechanism - view recycling would work perfectly, because it would create at most 2

Categories : Android

How to make 2 images views each be sized to cover screen inside a linear layout inside a horizontal scrollview
I'd be inclined to use a viewpager with a custom page adapter showing your scaled imageview instead of trying to do it in way you are currently. The view pager / adapter would handle view recyling, page snapping etc for you.

Categories : Android

Event Handler inside for views inside a fragment
Do you mean onClickListener? You can set: imageView.setClickable(true); imageView.setOnClickListener(new OnClickListener{...}); as usual, It is doesn't master whether it is in a fragment or whatever.

Categories : Android

Android custom listview inside a window
If what you want to do is a split view window with two diffrent Listviews that the one can pass data to another or update it in some way you need to take a look in List Fragments. There is a nice tutorial here : http://www.vogella.com/articles/AndroidFragments/article.html

Categories : Android

How to keep a dot drawn on canvas at a fixed point on screen, even when the canvas is pinch zoomed? - Android
Keep in mind that the canvas is thought to scale everything according to the scale factor, so while going against the zoom is possible, it is probably not the best approach. However, if this is what you're looking for, I will help you as best as I can. I am assuming the following: Scale factor is relative to the current zoom (old zoom is always scale factor 1). If this is not the case, then you should observe the zoom values after scaling roughly 200% two times and seeing if the resulting scale factor is 4 or 3 (exponential or linear). You can achieve the results below by normalizing the scale factor to 2 for a zoom factor of 200%, for example. You'll have to remember the old scale factor in order to do so. No rotation is performed If this is the case then following can be said fo

Categories : Android

Android - Displaying Custom ArrayAdapter inside ViewPager
The long and short answer is to never use ListActivity and ListFragment or any variant thereof. Just use regular fragments and activities, put a ListView into your layout. Create a private class adapter that extends ArrayListAdapter (or BaseAdapter or whatever). Assign an adapter to it on onActivityCreated() of your fragment ListActivity and ListFragment are so limited and attempt to hide and couple something that should neither be hidden nor coupled. Vogella has a great tutorial http://www.vogella.com/tutorials/AndroidListView/article.html No different to usage within a fragment.

Categories : Java

different ways of creating custom views / custom view not able to be interacted with when created from object library
It looks like you're loading testview from inside the testview class initialiser with a hacky check for subviews to prevent it from becoming recursive. Since the code outside probably also loads the nib, what you're actually doing here is loading the nib twice, once inside the other. If you set up the owner then the inner one will be setting the outlets on the outer one. It's just a guess as there is not enough information here to know for sure - but if you are setting outlets in your view class for some of the sub-views within it then you must supply an owner object to loadNibNamed:owner:options: with the type of your class. So you could pass self as owner in your code and this might work. However it's really the wrong way to use nibs for single-views. Instead of having the single view

Categories : IOS

Using custom attributes in custom views while in preview layout
You cannot do whatever you have in you line 35 when the application is not running, because design mode will get a null reference for some object that's only instantiated on the runtime. You have to avoid the execution of those in the design mode using isInEditMode(), like here: if(!isInEditMode()) { whatever there is in the line 35 of your class } If you need to perform some change in the view, and you want it to be visible on the designer, override onDraw(), like here: @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); TypedArray a = this.getContext().obtainStyledAttributes(attrs, R.styleable.DateTileView, 0, 0); String monthLabel = a.getString(R.styleable.DateTileView_monthLabel); Drawable monthBG = a.getDrawable(R.styleable.DateTileView_ti

Categories : Android

Android: OnClickListener on an ImageView inside a list item in a custom Listadapter
Change your OnClickListener to the following: detailsIcon.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { int id; id = (Integer) v.getTag(R.id.recording_id); System.out.println("View (ID: " + id + ") "); } }); When you call detailsIcon.setTag(R.id.recording_id, rec.getId()); you are setting the key for the tag to R.id.recording_id. You must use this key to retrieve the tag from the view. If you were trying to set the id of the view you can call detailsIcon.setId();.

Categories : Android

Include custom Activity inside of Unity Android Plugin (Without overriding UnityPlayerActivity)?
The best suggestion I can give is to use the Export build option (this will give you an Eclipse workspace-worth of projects, ready to run). Unity's activities are just code - so you can hook your own code into them, without having to subclass them. This does mean that you won't be able to use the normal Build and Build and Run builds (at least not when you want to test this particular functionality), but it will work. To make the process automatic on each build, you can write a post-build script in Unity.

Categories : Android

Difference between drawing directly to canvas and drawing on bitmap and then canvas in Android onDraw()
I disagree that you are saving much by going the bitmap route. You might consider a data structure that stores the drawn signal and converting this to a JSON object that can be serialized/deserialized. As for your question, this is an educated guess but it has more to do with rescaling of the drawn signal, since you are not using getHeight() when you create the bitmap.

Categories : Android

WPF Is Polygon inside a Canvas
You may check if the Rectangle returned from the Bounds property of the polygon geometry intersects with the Canvas Rectangle: var canvasRect = new Rect(canvas.RenderSize); var polygonRect = polygon.RenderedGeometry.Bounds; var intersects = canvasRect.IntersectsWith(polygonRect);

Categories : C#

Traversing through available Views inside ASP.NET MVC Application
You need to san physical files in Views folder. You can use code like this: var rootFolder = Server.MapPath("~/"); //recursivly get all the files from `rootFolder + "/Views"`

Categories : Asp Net Mvc

Views inside rows of TableView in iOS
Basically the 2 methods that you have to configure for the UITableView delegate method in order to achieve that results are: -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { if([indexPath row] == x) { return 44.0; } else { return 60.0; } } and - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; } if([indexPath row] == x) { [cellForB

Categories : IOS

Custom Views in a GridView
In your XML you gave android:columnWidth="90dp" and 10dp both vertical and horizontal spacing and then in your custom view implementation you gave 150 as width and height, and 8 as padding, basically they conflict, try to make both values convenient since the columnWidth you gave is way more less than width you gave in your custom view,

Categories : Android

Where should custom devise views go?
For own controller view you can try below one devise_for :members, :controllers => { :registrations => members_registration' } and views/members_registration/edit.html.erb in controller class MemberRegistrationController < Devise::RegistrationsController ... end

Categories : Ruby On Rails

Accessing Custom Views
Add a uiview element in xib and change its class to custom view class name. Then you will be able to access the instances from the custom view class. Or instead of creating an object of uiview type create object like Customview * newView = [customview new]; I tried this and i am able to access it. You are doing something wrong. Make sure you written accessor methods properly for the close and menu button. -(void)loadView { BKCCustomView *learnMoreView = [BKCCustomView new]; self.view = learnMoreView; //learnMoreView.uielementOfCustomView //which i am not able to access [learnMoreView.menuButton setBackgroundColor:[UIColor lightGrayColor]]; //i am able to access it [learnMoreView release]; }

Categories : IOS

Custom styling of views
Create your custom style in some XML file in res/values, for example res/values/styles.xml: <resources> <style name="CustomTextStyle" parent="android:style/TextAppearance"> <item name="android:textColor">#f00</item> </style> </resources> Then to apply this style to your TextView in code: yourTextView.setTextAppearance(context, R.style.CustomTextStyle);

Categories : Java

Animating an object inside a canvas
In general drawing to the canvas only ADDS new graphics - to do an animation you have to erase the background each frame. Specifically you need to have a draw function that is called repeatedly which: Clears the canvas ( draw a big background colour rectangle or whatever backdrop you want) Then draws all the objects that are moving. Using a fixed time period (30ms as you do) has a variety of problems - once you get this to work look around stack overflow to figure out how to match this framerate to the browsers redraw cycle.

Categories : Javascript

Animate bitmaps inside canvas
From Android's API Guide on Canvas and Drawables: Draw your graphics directly to a Canvas. This way, you personally call the appropriate class's onDraw() method (passing it your Canvas), or one of the Canvas draw...() methods (like drawPicture()). In doing so, you are also in control of any animation. This means you have to perform the animation yourself, frame by frame. If you don't actually need to draw complex graphics, consider switching back to standard views so you can use help class like AnimationDrawable. Check here for an example of how to do your own animation in Canvas.

Categories : Android

drawing a div element inside a canvas
You can't access an image stored as a CSS background image like that - there is no image element. It does work if the image is a real <img> tag within the <div> See http://jsfiddle.net/alnitak/DuCVG/1/ The (much harder) alternative would be to use window.getComputedStyle() to read the background-image CSS property from the element, parse it, and then create a brand new Image object that has the same source.

Categories : Javascript

moving a rectangle inside a canvas
Working version under, and demo here. I moved the clearRect to the update function so it would run before values changed. I added also if conditions so the img will not go out of the canvas. function update(event) { if (x + 20 > canvas.width() && event.keyCode == 39) { ctx.clearRect(x, y, width, height); x = canvas.width() - 15; render(); return false; } if (x - 10 < 0 && event.keyCode == 37) { ctx.clearRect(x, y, width, height); x = 5; render(); return false; } if (y - 10 < 0 && event.keyCode == 38) { ctx.clearRect(x, y, width, height); y = 5; render(); return false; }

Categories : Javascript

create Views from HashMap inside ArrayList
Construct a POJO Class for your Questions: Class Questions{ private String Name; private String field_type; private ArrayList option_value; <Getter and Setters> } Use this as a POJO class. And add this to the ArrayList. Using a Map is only when you require it. For transfering data using POJO/Business Objects are enough and best suited. Please let me know your thoughts.

Categories : Java

Cannot Access Views inside Included layout
Since a Project > Clean did not solve your problem, try setting the parent to the container currently visible in your Content View: (As you posted in your comment response:) inflater.inflate(R.layout.hourly_fragment, container, false);

Categories : Android

How to have partially sticky views inside a ViewPager?
I guess one idea would be to detect the page scrolling using onPageScrolled method, detect if scrolling direction is left or right, then manually update the position of the red circle accordingly. See also: How to know viewpager is scroll left or right?

Categories : Android

Modules views and actions inside tabs
The fact that you're using tabs shouldn't change much. I'd still create a separate module that handles the CRUD tasks for each tab. You just might need to use partials and embed them into your usario module's template. So for example, you could store each tab in a _form.php partial, and your structure might be something like this: app admin modules usario actions emplates editSuccess.php _form.php emisore actions emplates _form.php maquina actions emplates _form.php You can include each form partial in your user editSuccess.php template a few different ways. You can create

Categories : PHP

How to load MVC views inside navigation tabs
Seeing as you state that you are a beginner, you may wish to look at jQueryUI. It includes tabs with Ajax Functionality by default and it is simply a case of configuring your tabs as required. http://jqueryui.com/tabs/#ajax See how the href is used by convention? <div id="tabs"> <ul> <li><a href="#tabs-1">Preloaded</a></li> <li><a href="ajax/content1.html">Tab 1</a></li> <li><a href="ajax/content2.html">Tab 2</a></li> <li><a href="ajax/content3-slow.php">Tab 3 (slow)</a></li> <li><a href="ajax/content4-broken.php">Tab 4 (broken)</a></li> </ul> <div id="tabs-1"> <p>Proin elit arcu, rutrum commodo, vehicula temp

Categories : Jquery

Backbone Views within Views within Views - why does this.$el.html('insert some content here') do nothing?
I managed to sort this out, with a little help from this article here - Backbone View Nesting I rewrote the memberHomeView class and moved the region instantiation from the render to the postRender function. This then ensured that the template rendering had been completed, allowing the region to then instantiate correctly (It comes back to me now that this is why I created the postRender method in the first place. Here's the altered function... define(['ministry', 'jquery', 'views/v-header', 'models/m-ns', 'views/components/components', 'text!templates/hub/member-home.html'], function (Ministry, $, Header, Models, Components, TemplateSource) { var memberHomeView = Ministry.SecureView.extend({ name: 'Member Home', sectionName: 'Hub',

Categories : Javascript

Problems with custom canvas
I'm not entirely sure what you want your end result to look like, so I probably won't be able to suggest the exact solution you're after. That said, the reason you're obtaining small points on your screen, rather than rectangles, is because the canvas is rendering the innerRectangle of your Rect object, at the specified coordinates, but you're never initialising setting the dimensions of that innerRectangle. The dots you're seeing are those width/heightless rectangles, which are having the Black stroke rendered (the dot). You can see what's going on if you try something along these lines: public System.Windows.Shapes.Rectangle innerRectangle = new System.Windows.Shapes.Rectangle() { Width = 10, Height = 10 };

Categories : C#

How to construct custom views in xamarin
I would suggest checking out this Java Android tutorial to get an idea of what you need to setup: http://developer.android.com/training/custom-views/index.html You may need to create an attributes xml file for your custom view. Another approach you may want to consider is to use a fragment instead of a view: http://docs.xamarin.com/guides/android/platform_features/fragments/fragments_walkthrough

Categories : Android

can't use custom views for devise in namespace
Try this : # routes.rb devise_for :accounts, :except => [:sessions] scope '/business' do devise_scope :account do get '/login' => 'sessions#new', :as => :new_account_session post '/process' => 'sessions#create', :as => :account_session delete '/logout' => 'sessions#destroy', :as => :destroy_account_session end end If you want customize devise session, Any of the logic within that controller that you want to override you can override by calling that method and inserting your own logic. For the list of what's in that controller, you can view the code on their Github page. If you do not wish to override their methods you can either leave them out, or just call super. example : def new super end So, I suggestion for c

Categories : Ruby On Rails

How to get current row views in custom ListView?
I got it working now. Here is the code for anyone interested: holder1.imgBtnSocial .setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // TODO Auto-generated method stub FragmentViewHome homeFragment = (FragmentViewHome) activityf .getSupportFragmentManager() .findFragmentByTag("homelist"); // current position or whatever position you're looking for final int currentPosition = homeFragment.listview_t .getPositionForView((LinearLayout) v .getParent()) - 2;

Categories : Android



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.