w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Canvas Html5: multiple canvases and clearing one appears to clear the other canvas as well
You're loading your context from the same canvas object: var ctx = canvas.getContext( "2d" ); var ctx2 = canvas.getContext( "2d" ); Use this instead: var ctx = canvas.getContext( "2d" ); var ctx2 = canvas2.getContext( "2d" ); Now the only thing left to wonder is why are you using two canvas instead of just one? It looks like you're trying to overlay them but if you add a border you'll notice that one's on the bottom and the other is on top. What you really want to do is save your state before drawing one of the objects and then restoring to the previous state. I've created a new fiddle with an example of using one context (no requestAnimationFrame): http://jsfiddle.net/z5vtL/1/ Another issue with your code is that you're using setInterval instead of window.requestAnimationFrame.

Categories : Javascript

How do I clear the text in Android TextView?
Try this, public class AndroidDemo extends Activity implements OnClickListener{ Button add, clear; EditText text; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); add = (Button) findViewById(R.id.addBtn); clear = (Button) findViewById(R.id.clrBtn); text = (EditText) findViewById(R.id.display); add.setOnClickListener(this); clear.setOnClickListener(this); } @Override public void onClick(View v){ if(v == add){ text.setText(messages[new java.util.Random().nextInt(messages.length)]); }else if(v == clear){ text.setText(""); } } }

Categories : Android

How to clear and add new texts to a dynamically created TextView?
You can either add the text to the textbox when you are creating it or assign it a class variable when you create it and later on you can add text to it. TextView dynamicTextView; ... private void CreateNewTextView() { dynamicTextView = Your New Text View; } ... private void ChangeTheText() { dynamicTextView.SetText("new value"); } if you have more than one TextView you can create a class level generic list of TextViews and add them to the list and call them later. you can also create a map of all TextView so you can call them with their key as well.

Categories : Android

How to clear part of canvas?
Drawing past boundary The problem you are facing is in first instance the fact you are drawing before and after a 0-degree on the circle. This can be complicated to handle as you need to split in two draws: one for the part up to 0 (360) and one 0 to the remaining part. There is a simple trick you can use to make this easier to deal with and that is to deal with all angles from 0 and use an offset when you draw. Demo using redraw base (I moved it to jsfiddle as jsbin did not work for me): http://jsfiddle.net/3dGLR/ Demo using off-screen canvas http://jsfiddle.net/AbdiasSoftware/Dg9Jj/ First, some optimizations and settings for the offset: var startRadians = 0; //just deal with angles var endRadians = 300; var deg2rad = Math.PI / 180; //pre-calculate this to save some cpu cyc

Categories : Javascript

Clear modal views from memory
I found a solution: When you are finished with your separated modal view part, you just use [[self presentingViewController] dismissViewControllerAnimated:YES completion:nil]; and the app goes back to the last view controller, in this case the UINavigationController. And with this, it also deallocates the old views.

Categories : IOS

How to Rotate textview without canvas
TextView | Android developers link how about not extending TextView and using setRotation(float), setRotationX(float) (and y). Also dont forget to set the pivot points if necessary.

Categories : Android

Clear canvas in button click
import android.graphics.Color; @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); canvas.drawColor(Color.TRANSPARENT); for (Path path : _graphics) { canvas.drawPath(path, mPaint); } } or @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); mPaint.setXfermode(new PorterDuffXfermode(Mode.CLEAR)); canvas.drawPaint(mPaint); mPaint.setXfermode(new PorterDuffXfermode(Mode.SRC)); for (Path path : _graphics) { canvas.drawPath(path, mPaint); } } See this Doc for more info. Your clear method is wrong. public void clear(View v) { ((DrawingView)mView).clearView(); }

Categories : Android

Android : How to clear a text i.e. written by path on canvas
You have to invalidate your canvas to redraw it. public setText(String text) { mText = text; this.invalidate(); } public void onDraw(Canvas canvas) { super.onDraw(canvas); ... canvas.drawText(mText, x, y, paint); }

Categories : Android

Best way to "clear all" values in text fields in all views with XIB based tab bar application
Loop through all the viewcontrollers in your tabbarcontroller then loop through the subviews of your each view controller's view and if the view is a textfield, clear it. - (void)clearAll { for (UIViewController *vc in self.tabBarController.viewControllers) { for (UIView *view in vc.view.subviews) { if ([view isKindOfClass:[UITextField class]]) { UITextField *textField = (UITextField *)view; textField.text = nil; } } } }

Categories : IOS

HTML5 canvas - Cannot clear dirty pixels - Retina related
I'm not entirely sure, but I think this may have to do with the resolutions of the different screens. If you've ever looked at an html5 canvas on a smartphone, which most have a much greater resolution per sq inch than a monitor, then you'll see that the quality is much degraded because the web browser expands the 100px that you tell it to use to the same physical size, which ends up being around ~130px. I think the same is happening with your retina display because it uses a crazy good resolution. Basically, different screens have different pixel size ratios. To get around this, I added the following to my code. var PIXEL_RATIO = (function() { var ctx = document.createElement("canvas").getContext("2d"), dpr = window.devicePixelRatio || 1, bsr = ctx.webkitBackingStorePixelRa

Categories : HTML

Textview with long text pushes out other views in GridLayout despite ellipsize=end
I'm a big fan of LinearLayouts, so here's my suggestion using those: <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_weight="1" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:ellipsize="end" android:singleLine="true" android:text="Long text to demonstrate problem with TextView in GridLayout taking up too much space despite ellipsis" /> <TextView

Categories : Android

TextView: Only the original thread that created a view hierarchy can touch its views
as in log: CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views. means you are trying to update or access UI element from non ui Thread so use Handler or runOnUiThread for updating Views from non UI Thread

Categories : Android

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

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

When Zoomed the canvas and then pan, now if I am trying to drag the objects within canvas then not able to do so. But canvas is panning only
If I understand correctly you must change coordinates and widthheight of image on your scale You want to do something like this - http://drag.com.hostinghood.com/?

Categories : Javascript

android: how to display textview ending with ellipse follwed another textview
Believe you want something like that: <LinearLayout ... android:orientation="vertical"> <LinearLayout ... android:orientation="horizontal"> <TextView ... android:ellipsize="end"> </TextView> <TextView ....> </TextView> </LinearLayout> <LinearLayout ... android:orientation="horizontal"> <TextView ... android:ellipsize="end"> </TextView> <TextView ....> </TextView> </LinearLayout> ..... </LinearLayout>

Categories : Android

Pocket-like TextView automatic spacing based on TextView width?
What you're referring to is called text justification and is something that has been discussed more than once here on SO in the context of Android. The short answer is that, unfortunately, justification is currently not (natively) supported by the TextView widget. There are however workarounds that involve either: Manipulating the text in the TextView in such a way that the result is visually close to that of justification. Example. Using a WebView to render the text. Example. Justifying text on a web page is trivial, but the WebView is a more heavyweight component than a TextView, and hence the feature will come with a performance penalty. Note that I don't know what approach Pocket is using for their articles, but there are ways to figure that out, and they're not too complicated.

Categories : Android

Passing a TextView or TextView Array to a function in Android
Generally it's not a good idea to pass them to function... but if you want you can try something like this... TextView[] STATVIEW = new TextView[SIZE]; then to initialize STATVIEW[0] = (TextView) findViewById(R.id.place_stat1a); //Team 1 STATVIEW[1] = (TextView) findViewById(R.id.place_stat1b); ...... then pass your Array postStats(STATVIEW); Alternative would be create a method and pass the values and set them to TextViews something like this public void fillData(String[] data) { for (int i=0;i<STATVIEW.length;i++) { STATVIEW[i].setText(data[i]); } }

Categories : Java

change textview background until select another textview in android
Dynamically change it in your code on selection of another TextView use yourTextView.setBackgroundDrawable(getResources().getDrawable(R.drawable.best_deal_bg)); and if you want remove the background use yourTextView.setBackground(null);

Categories : Android

Android XML ImageView below TextView but needs to align bottom with textView
You use android:layout_alignBottom="@+id/idOfText" when you first make a reference to a particular id. Note the "+" which is adding the id to the list of resource identifiers. Then, you can assign an existing id to a widget without using the "+", as follows: android:id="@id/idOfText" after. It's typical to create the id when we're assigning it, which is why you only really need to care about the presence of the "+" in relative layouts. In your specific case: <ImageView android:id="@+id/chatBalloon" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:layout_marginLeft="-5dp" android:layout_marginRight="-5dp" android:layout_marginTop="2dp" android:layout_toRightOf="@id/chatItemPro

Categories : Android

Confusion between "#define clear()" and "std::wstring::clear()"
The reason is because the preprocessor basically does a search-and-replace on all macros that are defined. And it's done before the compiler proper gets the code, and it does not know anything about namespaces, classes or scope in general. So if you have e.g. #define clear() something and then use wstr.clear(); The preprocessor will replace the clear() so that the compiler sees wstr.something;

Categories : C++

How to clear the bottom of an image like clear left / right
Based on your image, you can realize the layout by using the the following HTML: <div class="contentpart"> <a href="#"> <img src="http://placehold.it/300x200"> </a> Donec adipiscing, lorem non euismod venenatis... </div> and applying the following CSS rules: .contentpart { border: 1px dotted gray; display: table; } .contentpart a { display: table-cell; vertical-align: top; padding-right: 20px; } You can see the demo at: http://jsfiddle.net/audetwebdesign/wknjA/ How This Works You can use CSS tables to get the text to stay in a single column without wrapping it in a block element. Apply display: table to the parent block and display: table-cell to the a tag. You can have some control over white space by

Categories : CSS

Set the textView visible to the top of the containing text (scrollable textView)
What about textViewDesc.setScrollY(0) ? Also, I've noticed that TextView scrolling is pretty unreliable. What about putting your TextView inside a ScrollView instead? (http://developer.android.com/reference/android/widget/ScrollView.html)

Categories : Android

Android Cant get One TextView to animate to the position of another TextView
Ok I found the error in my code. If anyone is having problems then use this : Animation a = anim.fromAtoB(0, 0, to_x-x_from, to_y - y_from, animL,1000); instead of Animation a = anim.fromAtoB(x_from, y_from, -to_x, -to_y, animL,1000);

Categories : Android

textView resizes to longest TextView in the tableLayout
You are using same instance of edit everywhere, so next time when you get your text larger, it wraps the larger text, so it makes its(edit) previous instances larger as well. One possible solution is to create a new instance of edit each time you add your text.

Categories : Java

How to drag the TextView to the correct target other TextView
Try the following code, it should work according to your description in the question. I have added an extra thing i.e. reset button as I felt it necessary. picture_to_word_24_color.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" android:padding="10dp" android:paddingLeft="50dp" android:paddingRight="50dp" > <TextView android:id="@+id/option_1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_margin="5dp" android:background="@drawable/option" android:gravity="center" android:text="Apple" android:textStyle="bold" /> <TextView android:id="@+id/option_2" android:l

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

Running a linux command from Django views. Works fine in python shell. Won't execute from views
You should look at the error log in order to make a proper diagnostic. Without more information, I can think of two reasons: The Apache mod_wsgi restricts access to stdout, and the command you are running outputs to stdout. If you are using mod_wsgi, look for errors like IOError: sys.stdout access restricted by mod_wsgi in the logs; You are testing your command while logged in as your user or root, but the webserver is running as other user with less privileges (like www-data in Ubuntu). Find out under what user the webserver is running, su to the same user and try the same commands. Any error will hint you about the permissions lacking. It is almost always a bad idea to run a shell from a Django view, specially if the command take a few seconds to run. It has bad scalability, makes e

Categories : Python

Please assist in mod rewriting application/views directory to "views" in Kohana
You have two problems here: Your rule to rewrite /application/views/... to /views/... is after the rule that rewrites everything to index.php. You need to put the more-specific rewrite before the more-general rewrite to prevent the more-general one from stopping the processing. Your rewrite rule is incomplete. You have a rule so that requests to /application/views/... get rewritten as if the files are actually at /views/.... However, since you are still actually storing the files in the application/views/ folder, you are missing the rule that lets you access them as if they are at /views/.... Here is one way you could make the rewrite rules in order to get it to work. (I left out the rule that redirects /application/views/... to /views/... because I don't see why you need it - just

Categories : Htaccess

Stop MouseEvent-propagation of displayList views to starling views
You could create 1 main container in the displaylist (not the stage) and listen for ROLL_OVER and ROLL_OUT, and set somekind of global flag there, that your mouse is over the display-list container. Then in your starling events, check for this flag. This isn't the nicest solution out there i guess, but it should work var isOverDisplayList:Boolean = false; container.addEventListener(MouseEvent.ROLL_OVER, onRollOver); container.addEventListener(MouseEvent.ROLL_OUT, onRollOut); function onRollOver(e:MouseEvent) { isOverDisplayList = true; } function onRollOut(e:MouseEvent) { isOverDisplayList = false; }

Categories : Actionscript

Dismissing both UINavigation views and Modal views at once programmatically
You could try replacing [self.dismissViewControllerAnimated:YES completion:nil]; with self dismissViewControllerAnimated:YES completion:^{ [parentViewController.navigationController popToRootViewControllerAnimated:YES]; } I believe parentViewController will point to the presenting view controller, and the block will cause the parent view controller's navigation controller to pop to the root view controller.

Categories : IOS

Node.js install canvas failed on mac osx 10.8.4 : src/Canvas.h.....fatal error: v8.h file not found
To fix it: Download the source code of node 0.10.13 from http://nodejs.org/dist/v0.10.13/node-v0.10.13.tar.gz Extract this file via tar -xvz node-v0.10.13.tar.gz Copy the 'deps', 'src' and 'tools' folders into '~/.node-gyp/0.10.13' Then run 'npm install canvas' again. I have no idea why the MacOS node package(just for v0.10.13) is missing these things.

Categories : Osx

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

Simplest slideshow in HTML5 canvas, canvas.context.clearRect not working with setTimeout
You have a few issues with that, including naming your image variables wrong. Try this: // 4 images var image0 = new Image(); image0.src = "http://placekitten.com/200/300"; var image1 = new Image(); image1.src = "http://placekitten.com/205/305"; var image2 = new Image(); image2.src = "http://placekitten.com/300/400"; var image3 = new Image(); image3.src = "http://placekitten.com/800/600"; // array of 4 images images = new Array(image0, image1, image2, image3); // global counter and canvas var counter = 0, ctx, interval; // this is the main function function draw(){ myCanvas = document.getElementById('myCanvas'); ctx = myCanvas.getContext('2d'); interval = setInterval(draw_next_image, 1000); } // this is the function called after each timeout to draw next image function dra

Categories : Javascript

Should Facebook canvas apps behave same if opened from original non-canvas site url?
Yes, you have more tools available in the canvas ("apps.facebook.com.."), as it will send you the user-id without any user consent. Has the user previously used your app, you will also be able to get their accesstoken and fetch more info about them. It requires some backend code to decode the signed request parameter, which provides you this stuff. This example is how php handles signed request: https://developers.facebook.com/docs/facebook-login/using-login-with-games/ If you're using C#, download the Facebook C# (available through NuGet, the package from Outercurve Foundation) and use this example: How do I parse a signed request in Facebook C# SDK? I try to handle the user in Facebook context whenever possible. It adds trust and more tools. Although since the Facebook phone/tablet

Categories : Facebook

Android multiline TextView , check if text fits , or check is TextView is full
For checking whether a multiline (or not) TextView is going to be truncated, check this post. Or, have you looked into using a scrolling textview? (marquee).. where the text will scroll by (horizontally, animated) if it is too long for a given width? Here is an example TextView in a layout file, that has some of these characteristics: <TextView android:id="@+id/sometextview" android:layout_width="wrap_content" android:layout_height="wrap_content" android:ellipsize="marquee" android:marqueeRepeatLimit="marquee_forever" android:singleLine="true" android:scrollHorizontally="true" android:focusable="true" android:focusableInTouchMode="true" android:freezesText="true" android:textColor="#808080" android:textSize="14sp" android:text="Thi

Categories : Android

Java clear console error: java.io.IOException: Cannot run program "clear"
There's pretty much nothing in the console related API to do a clear screen. But, I think you can achieve the same effect through println()s. A lot of putty clients clear the page like that and then scroll up. private static final int PAGE_SIZE = 25; public static void main(String[] args) { // ... clearScreen(); } private static void clearScreen() { for (int i = 0; i < PAGE_SIZE; i++) { System.out.println(); } }

Categories : Java

Java ScrollPane and Canvas - Lock Canvas to JScrollPane size
and scrap the use of Canvas Swing is double buffered by default. Try just using a JPanel. I need strict control over the resizing of a child component within a JScrollPane such that it either locks to the size of the JScrollPane (so that no scrollbars appear) or stays fixed to a predefined size (and let JScrollPane show scrollbars when appropriate) You might be able to use the Scrollable Panel. You might be able to toggle between NONE and FIT for the ScrollableSizeHint.

Categories : Java

Html5 canvas game, creating a map much bigger than viewing canvas
I'll give it a shot anyways. So, for the theoretical part: What you are trying to achieve is simple Scene Management. A Scene needs a Camera, an object that stores the X and Y offset and the Width and Height it is going to display (The Width and Height is also known as the Projection Plane in 3D graphics). In every frame you will draw your Scene (or World) by the offset of your Camera. To the implementation: To draw a large image onto a small Canvas, just use the drawImage() function with all 9 parameters as you allready do. To draw many small images like Tiles, i recommend taking a look at Scene graphs, i wrote a more in-depth answer some time ago at Collision detection in HTML5 canvas. Optimization too If you draw many Objects per frame, note that you can always create canvas object

Categories : Javascript

html canvas: insert multiple images into separate canvas
JavaScript's var variable declaration is function scoped, not block scoped. Your context is being overwritten every time the loop runs. Instead of that for-loop, use jQuery's .each() function: $(".drawing-result").each(function (i, canvas) { var context = canvas.getContext('2d'); var imageObj = new Image(); imageObj.onload = function(){ context.drawImage(this, 0, 0); }; // skipping the code for retrieving dataURL using data-id imageObj.src = dataURL; });

Categories : Javascript



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