Posts by Paulo Roberto Rosa • 8,979 points
159 posts
-
5
votes2
answers1434
viewsQ: Problem when performing XHR on the same domain (localhost)
Explanation: I have an application running on a client’s computer, it worked normally for some time, then something happened that the system could only be accessed from outside and locally no longer…
-
1
votes0
answers127
viewsQ: How to use jqZoom on a Base64 image?
Situation: I have a small application where the user chooses an option from <select> and in that an image is loaded via javascript using Base64. Problem: The jqZoom plugin does not work…
-
9
votes9
answers2096
viewsQ: How to assign a function with parameters to click without executing it?
Explanation: I have an application that has by default an event mostraGrupos() and when it is executed, at the end it detaches itself from the element and tries to assign the function…
-
20
votes1
answer15905
viewsQ: How to rescue the GPS location in coordinates, from all users of the application?
Explanation/Scenario: I am developing an application that must redeem in real time the location of users of the same, and these users aware of this, will also, access the location of other users, in…
-
0
votes2
answers410
viewsQ: Unknown Error: "null" when running an Httppost with Parameters
Explanation: I own a simple Android app, and also a Nodejs server. I have the following permissions on AndroidManifest.xml of my application: <uses-permission…
-
0
votes1
answer130
viewsQ: How to access the View that triggered one of the events of a Textwatcher?
Explanation: I have a common application where there are several components EditText, where I assign them an Handler that would be this one: TextWatcher handler = new TextWatcher() { @Override…
-
1
votes2
answers473
viewsQ: How to call the Horizontal Keyboard when clicking on Edittext?
Explanation: I have an application that has a field of type EditText used for observation, of which it is too small, because there is no room for it. If I open the screen in "horizontal orientation"…
-
1
votes1
answer559
viewsQ: What would be an alternative to the "obsolete" showDialog function?
Explanation: I have a mobile application that uses the method showDialog() at a given time, to show a DatePickerDialog and get the date, but I see that on the following line:…
-
0
votes7
answers175
viewsA: Contact Form
A simple three-line solution using ternary operator would be: $phone = (isset($_POST['phone'])) ? (is_numeric($_POST['phone'] && strlen($_POST['phone']) >= 9) ? $_POST['phone'] : ""; if…
-
1
votes2
answers1309
viewsA: Error calling method on fragment
In theory and practice the best to do is the following: Change the scope of your method by making Static: public static void chamaCadastro(){ setContentView(R.layout.cadastros); } Create a separate…
-
4
votes3
answers3627
viewsA: How to Lock a Responsive Page in Portrait(Picture)?
You can try to run the body of your page or certain div that it involves, in the event "orientationchange" using jquery: $(window).bind("orientationchange", function(){ var orientation =…
-
1
votes7
answers6999
viewsA: Split() integer with Javascript
To answer your question "Split integer with javascript": It is not possible. Even because Javascript does not work with Integer(Integer) numbers, it only works with Number(floating number). But I…
-
23
votes5
answers22471
viewsA: How do anonymous functions work?
Literally answering your question "How anonymous functions work?": Anonymous functions are very important to understand some of the concepts of how Javascript works, are functions that do not depend…
-
2
votes1
answer377
viewsA: Error - Nullpointerexception
As you can see in this line of error: 03-20 10:03:32.510: E/AndroidRuntime(940): Caused by: android.database.sqlite.SQLiteException: near "9851": syntax error (code 1): , while compiling: insert…
-
10
votes3
answers24782
viewsA: How to sort an array by values?
Explanation: By default, the function sort() javascript lexically sorts your Array. But optionally you can pass a function in the input parameter, so that it returns the desired result. About the…
javascriptanswered Paulo Roberto Rosa 8,979 -
1
votes3
answers923
viewsA: Error ""AWT-Eventqueue-0" java.lang.Stringindexoutofboundsexception: String index out of range: 0" in Java when trying to do IF
You can solve your problem by assigning ternary operator verification directly to the variable, so you don’t have to convert it and access it again to any verification, saving unnecessary code and…
javaanswered Paulo Roberto Rosa 8,979 -
2
votes3
answers1456
viewsA: Encapsulate values returned by JSON within a single object
Answer to your question "How do I return JSON this way? It just doesn’t. You cannot return a JSON this way because the JSON syntax does not allow, the format most suitable for your object is for…
-
2
votes3
answers388
viewsA: Date reassembly with javascript
Well, your question is "How I remodel the date in javascript?" And I say to you, it’s simple, to mount a date you have the Javascript Date Object: var a = $("input[name='txtAno']").val(); //ano var…
-
2
votes2
answers1318
viewsA: How to write HTML inside Ajax Success
You can use an HTML String and play it in your document this way: var item = ""; $.ajax({ type: 'POST', url: "@Url.Action("_ListaHistorico", "Solicitacoes")", data: { IdSolicitacao: id}, dataType:…
-
5
votes4
answers349
viewsA: Every N repetitions display X in PHP
You could do it: <?php $counter = 0; do { $counter++; if ($counter == 4){ ?> <div class="fotos ocultar"> <?php } else { ?> <div class="fotos"> <?php } ?>…
phpanswered Paulo Roberto Rosa 8,979 -
5
votes2
answers114
viewsA: Good practice with css selectors
Best practice would be to need less code for everything to work properly, which would not need many classes, but only one parent class accessing the children in this way: .menu li { //codigo } So…
cssanswered Paulo Roberto Rosa 8,979 -
4
votes5
answers2024
viewsA: Replace If/Else with Case javascript
In your case, to facilitate understanding and decrease lines of code, it is not necessary switch(case) nor if&else, you can only use Array'as demonstrated in part of the @mgibsonbr(condition…
-
1
votes2
answers9591
viewsQ: How to avoid SQL Injection in my PHP application?
Explanation: Most applications using PHP, should receive parameters, by $_GET or $_POST and these parameters often become an easy target for users with bad intentions, and this is called SQL…
-
3
votes2
answers9591
viewsA: How to avoid SQL Injection in my PHP application?
Personal comments I see several people, including here at SOPT, making the mistake of leaving their application vulnerable to SQL Injection, of course due to lack of information, however it is of…
-
6
votes1
answer6370
viewsA: How to clone an element with jQuery and add a new name?
To clone your element, and set the name to the previous name with a value +1, just do as follows: function adicionar(){ var ElementoClonado = $(this.parentNode).clone(); //clona o elemento var str =…
-
1
votes1
answer1064
viewsA: Convert Bitmap/Drawable to Drawable (int)
To convert a Bitmap in Drawable do the following: Drawable seuDrawable = new BitmapDrawable(getResources(),seuBitmap); However, as you requested, you need to get the Drawable by id then use: Bitmap…
-
3
votes2
answers946
viewsA: Query the return of an Ajax
Your ajax does nothing when completing, but you must do an action that would fill your list with the returned elements in this way for example: $.ajax({ type : 'POST', url : 'index.php/home', data :…
-
4
votes1
answer1988
viewsA: Multiple layouts in one Activity - how to use?
The Difference Between Your Layout’s From what I see, you have two Layout’s practically equal, with only a few minor changes (the ID’s), outside the ID’s would be the button btnSave and the…
-
10
votes3
answers39348
viewsA: Function to add more hours or days to a date
Answering your question itself "Function to add hours or days to a Date": You want a function to do this for you, well, it’s an easy task, just as you can see in the @Gypsy, may not need a function,…
javascriptanswered Paulo Roberto Rosa 8,979 -
0
votes1
answer1035
viewsQ: How to download a file and open it at the end of the download?
I have an Android application, I’m trying to download a .apk and then open it when the download is finished, follow the code used: /** * baixando arquivo na background thread * */ @Override…
-
5
votes2
answers537
viewsA: How to avoid calling the function
You can solve this easily by stopping the animation using .stop() before giving .fadeOut() and it might get even better if you also give a .stop() in the .fadeIn() also because I performed some…
-
6
votes3
answers4187
viewsA: How to Make a Submenu in Action Bar?
To have a submenu, you must have a menu within a menu. Using XML This way: <?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android">…
-
9
votes7
answers3980
viewsA: How to check if there are numbers inside an input with Javascript?
I recommend the use of the property Pattern from HTML5 for a type check, as it is not necessary to use Javascript. In this case, your html would be the following: <input type=nome…
javascriptanswered Paulo Roberto Rosa 8,979 -
2
votes2
answers8992
viewsQ: How do I update my application’s APK when the user requests it?
Explanation: I have an application that is constantly made quite changes, and every time I do, I get a new version with the same Private Key(Keystore), I mean, when I send the new *.APK install on…
-
46
votes6
answers5796
viewsA: How is computer randomization generated?
The randomization made by Math.random() returns a positive value (greater than or equal to 0) of the type Number, but less than 1, it is randomly chosen or pseudo randomly with a uniform…
-
1
votes3
answers3827
viewsA: How to scroll infinity with pure javascript?
With the code you developed here that would be: var count=0; function Picture(){ if (event.wheelDelta >= 4){ if(count == 3){ count=-1; }else{ Resize(++count); } } else if (event.wheelDelta <=…
-
0
votes4
answers1363
viewsA: How to change an element within a Less file?
As @bfavaretto said, there is no way to change the LESS variable using js, but having a little work you can change the properties to static values that would be, for example, through a function:…
-
5
votes2
answers824
viewsA: Name of months in Portuguese and English
To solve this, create a page called index.php, within it, you will have language options, only flags of each country for example. You will then have a choice, which depending on the choice you will…
-
4
votes3
answers4074
viewsA: Show/Hide animated information by clicking on the widget
You can easily do this using the method .animate() jQuery : Example: HTML: <div class=container> <div class=circulo>Mais</div> <div class=close>X</div> </div>…
-
1
votes3
answers2397
viewsA: jQuery autocomplete shows no options
The problem is that the source: jQuery Autocomplete UI requires an array of strings and not a JSON, see how it would be functional: First you’d have to put descricaoProduto in an array, and then…
-
3
votes2
answers6229
viewsA: Change image src through jquery
It’s simple, using jQuery you can do the following: var vectorImagens = ["images/medium/3.jpg","images/medium/4.jpg"];//exemplo var len = vectorImagens.length; //tamanho do vectorImagens var imagens…
-
0
votes2
answers1722
viewsA: Column size on a Gridview on Android
The solution is simpler than it seems: First: You should check if the LinearLayout that you are involving her GridView is with android:orientation="horizontal", If it’s not, you should put it on.…
-
9
votes3
answers18362
viewsA: How to preview a loaded image in an "file" input?
You can simply take the input value and play as src of an image, just add this function to your example: function readURL(input) { if (input.files && input.files[0]) { var reader = new…
-
6
votes2
answers5355
viewsA: Get colors from the image
You can use the technology Canvas which is contained in the browsers that support HTML5(currently most), and with it you can make a Javascript function that takes as a parameter your image and…
-
0
votes3
answers1752
viewsA: How to take the current position of a div by his class?
You can use the function index() jQuery, working as follows, in your case I will exemplify with a click event: $('.position').click(function(){ alert($(this).index()); });…
-
1
votes2
answers2126
viewsA: Error making Ajax request
Obs: There’s a question that’s extremely similar to yours here, the image is identical. Translated Response from SOEN The feature could be being blocked by an extension (Adblock, etc..) The message…
-
4
votes2
answers5577
viewsA: How to see if a "file" input file has been selected?
You just need to, at the event change() of your <input type=file> check the value of it, if it is different from empty, show the add another button, which would be hidden until then(guess) and…
-
12
votes8
answers45427
viewsA: How to disable the scroll of a web page?
You could use javascript to lock the scroll anyway, always setting the top to 0, each time any scroll event is called, see: function setTopo(){ $(window).scrollTop(0); } $(window).bind('scroll',…
-
8
votes2
answers579
viewsQ: Why does setting a CSS property with the ! attribute not work in the . css() method?
I would like to know the real reason for the disability that the function jQuery.css() has, which would be the fact that when using the attribute !important in any assigned CSS property, the same is…
-
8
votes3
answers22986
viewsA: How to add +1 in a counter variable to each click?
Would this be? HTML: <input type=button id=addCount value="Adicionar Count"> Javascript: var count = 5;//recebendo o valor 5 que você disse $('#addCount').click(function(){ alert(count);…