Posts by Pablo Almeida • 5,060 points
155 posts
-
1
votes1
answer106
viewsA: Assign a color to the added image with "android:drawableLeft"
With the help of Appcompat, it is possible, yes. Given the following provision... <?xml version="1.0" encoding="utf-8"?> <RelativeLayout…
androidanswered Pablo Almeida 5,060 -
4
votes3
answers604
viewsA: High-box text button in Android API < 14
The ideal is to do as the @ramaral colleague suggested and use Appcompatbutton, since it is part of an official library, tested, debugged etc. But, for those who have some restriction on the use of…
-
2
votes3
answers580
viewsA: Grab a JAVA array
Java does not know what order you are in switch will be executed, since it depends on how the execution will take place. And if you fall into the case 2 before falling into the case 1? Will not…
-
1
votes1
answer317
viewsA: Error while compiling Android
Some of your project’s dependencies have been compiled with Java 8, but you’re using Java 7 in the project. Put your project to use Java 8 or recompile the library that is causing the problem after…
-
1
votes1
answer2620
viewsA: "Nameerror: [word I typed] is not defined" when trying to read from keyboard
Solution: You are using Python 2 and the tutorial must be using Python 3. Use Python 3 or swap input for raw_input. Explanation: The function input Python 2 is not to read strings, but to read…
pythonanswered Pablo Almeida 5,060 -
0
votes2
answers117
viewsA: list.remove() in a row
If you don’t mind generating a new list with the results, you can do: >>> [elemento for elemento in lista if elemento.strip() != ""] ['a', 'b', 'c'] If you are sure that your list only…
pythonanswered Pablo Almeida 5,060 -
1
votes3
answers317
viewsA: How to not distort the layout when opening the keyboard?
The option you are looking for is to adjustPan. In Manifest, put in the entry corresponding to your Activity: <activity ... android:windowSoftInputMode="adjustPan" ... > </activity>…
-
2
votes2
answers63
viewsA: Looping for as a looping parameter while
Yes, but try without the while: for letraF in [letra for letra in cont if letra == 'f']: print(letraF)
-
1
votes2
answers146
viewsA: How to close a running audio
The MediaPlayer has methods pause() and stop() which serve to pause and stop the audio execution respectively. The problem here is that you are creating the MediaPlayer as a local variable to your…
androidanswered Pablo Almeida 5,060 -
3
votes1
answer35
viewsA: How to differentiate buttons from a Listview?
You can associate a slightly different Switch for each of these buttons directly in the Adapter. Your getView would look something like this: public View getView(final int position, View…
androidanswered Pablo Almeida 5,060 -
1
votes1
answer137
viewsA: How to download a database and insert it into the app?
You don’t do that. The Assets is for static features, available during application construction. You should save custom or dynamic data to your device, not APK. Depending on what you intend to do,…
androidanswered Pablo Almeida 5,060 -
0
votes1
answer46
viewsA: Second response of the Web Service still has the value of the first
From what I’m seeing, in your capacity comandaDetalhes, you start a Thread but immediately returns this variable n, which is the variable that will receive the value of the answer when it ends,…
-
0
votes1
answer96
viewsQ: How to align an element of a Collapsingtoolbarlayout to the title?
I have a CollapsingToolbarLayout with a LinearLayout inside (which contains some texts). Toolbar title has a default margin on the left (at least on LTR devices) when it is expanded and a different…
-
0
votes1
answer96
viewsA: How to align an element of a Collapsingtoolbarlayout to the title?
One solution is to apply the same value to the bar title margin (via the attribute expandedTitleMarginStart) and the element containing the text. In my case, android:layout_marginStart. Example:…
-
0
votes1
answer101
viewsA: Still need to restore Activities when rotating the phone?
It’s still necessary, yes. What happens is that many components already do this restore for you automatically, so you don’t notice. A text field can, for example, save what was written on it and…
androidanswered Pablo Almeida 5,060 -
2
votes1
answer2503
viewsA: java.lang.Runtimeexception: Unable to instantiate Activity Componentinfo
You are assigning the Views of his Activity to the variables (findViewById...) before the onCreate (by placing them at the top of the class). Consequently, you are doing this before the…
-
4
votes1
answer55
viewsA: How to handle requirements that "mix" domain and interface?
I guess it’s not exactly a layering problem. You’re too focused on the domain as an abstract thing and forgetting that the business layer has to model the customer problem, not a generic problem.…
-
1
votes1
answer101
viewsA: Icon gets small in notification
You need to set which is the big icon of your notification with setLargeIcon. If you do not set, the small is used in place and does not grow alone.…
-
1
votes1
answer89
viewsA: Listview error with Arrayadapter and Custom View
On the line convertView = LayoutInflater.from(this.context).inflate(R.layout.principal, parent, false); You are inflating the XML for the layout called "main", which seems to correspond to an…
-
1
votes1
answer1161
viewsA: Typeerror: start() Missing 1 required positional argument: 'self' when trying to use the Chronometer module
When you do... from chronometer import Chronometer as crmt ...you are importing the class Chronometer module chronometer to the current namespace and nicknamed it crmt. Note that…
-
1
votes1
answer68
viewsA: What is missing from the custom listAdapter I created?
You’re passing ints for the setText of TextView on the line txtPosicao.setText(posicao[position]); This causes it to be called the method setText(int resId), which will attempt to define as text the…
-
3
votes2
answers294
viewsA: Do threads share the same memory address as an object method?
Your case has one peculiarity: you’re going through the same Runnable for all the Threads. That Runnable is associated with the object MinhaClasse current (this) by means of the method FacaAlgo. It…
-
2
votes2
answers1472
viewsA: How to destroy my Activity?
You don’t do that. The method OnDestroy not to destroy your Activity, but to react to its destruction. Who destroys your Activity is Android. Typically, the "back" button of the device prompts the…
-
2
votes2
answers75
viewsA: Avoid successive getElementById calls with the same parameter
A simple solution is to create a local variable to your function to store the result and use that variable from then on: function valida_form(){ var filter_nome = /^([a-zA-Zà-úÀ-Ú0-9]|-|_|\s)+$/ ;…
javascriptanswered Pablo Almeida 5,060 -
5
votes5
answers993
viewsA: What is the difference between referencing an attribute directly or by get/set
First of all, you spoke about security. Security is not the intention to choose to use private variables. The intention is to protect against programming flaws (especially coupling) that lead to a…
-
1
votes5
answers13398
viewsA: How to declare a date variable in C?
Note that it is not necessary for each data to be mapped to a variable in its structure. With this in mind, a simple solution is to have one variable for day, another for month plus one for year of…
-
0
votes2
answers131
viewsA: Project imported from Eclipse to Androidstudio has no R reference
One of the possible causes is some syntactic problem in one of your XML. Remember that the R.java file is a file generated to allow your Java codes to reference XML elements. When there is a problem…
-
5
votes3
answers1140
viewsA: Methods with the same name but with a number of different parameters
It’s called overload of methods. No, this is not possible the way you are wanting to do in Javascript. However, Javascript does not reject passing a number of parameters other than what is stated in…
-
1
votes2
answers272
viewsA: Items of B whose indices are the positions of occurrences of equal elements in A
First, let’s create a collection from A without repeated values: ASemRepetidos = set(A) For each element of this set, we will find the index of its occurrences in A. When you need indexes, the…
-
16
votes1
answer150
viewsA: If is executed even with the condition being false
You have a semicolon in front of your condition if: if( min >= t && t != -1); Regardless of the outcome, nothing will happen. Then you have a loose block: { printf("oi\n"); min = t;…
canswered Pablo Almeida 5,060 -
2
votes3
answers425
viewsA: How to define a function that calculates the lowest speed?
I’ve made some changes. It’s like this: def velocidadeEmMetrosPorSegundo(Vi, A, T): V = Vi + A * T return V * 3.6 vi1 = float(raw_input()) a1 = float(raw_input()) t1 = float(raw_input()) V1 =…
-
3
votes3
answers1388
viewsA: Minimum search from a list ignoring zero values
menorNumero = min(numero for numero in B if numero != 0) indiceDoMenorNumero = B.index(menorNumero) I’m applying the function min, that takes the smallest value from a list to a generating…
-
1
votes3
answers3525
viewsA: Brazil default date format does not work on bootstrap
You are using the wrong format. According to documentation of Datepicker: dd - day of Month (two Digit) [...] DD - day name [...] mm - Month of year (two Digit) [...] MM - Month name long Therefore,…
-
1
votes1
answer57
viewsA: Error : Arraybuffer is Undefined
How can you check in compatibility tables, in Internet Explorer 9 and earlier, ArrayBuffer just doesn’t exist. On the 10, you shouldn’t be getting this mistake. If you have problems with archaic…
-
3
votes2
answers538
viewsA: Exception in thread "main" java.lang.Unsupportedoperationexception
The problem is that Arrays.asList returns a list of fixed size. You are trying to modify this list, so you get the exception. To documentation calls it the "bridge between collections and arrays…
-
2
votes2
answers87
viewsA: Javascript - IF running before time
It seems to me that you didn’t understand a fundamental point of Javascript, which are the asynchronous functions. Note that the code you want it to execute before the if belongs to an anonymous…
-
0
votes2
answers362
viewsA: I cannot assign value to an Object Arraylist
It seems to me what you want is to insert a new Cliente on the list. Starting from this assumption: First, create a copy of Cliente and assign the name you want: Cliente novoCliente = new Cliente();…
javaanswered Pablo Almeida 5,060 -
2
votes1
answer334
viewsA: Request by browser works, but Java gives error 301
Do you know what 301 is? It’s not exactly a mistake, but rather the permanent redirection indicator code. The server is warning the HTTP client that the content has been moved to another URL. When…
-
4
votes2
answers1291
viewsA: Bigdecimal comparison returns unexpected result
You’re actually comparing 100 to 50. In English, the dot separates the entire part of the fractional part of a number from the comma. As indicated in official documentation, the BigDecimal accepts…
-
2
votes3
answers182
viewsA: Foreign value when printing array
What you are seeing is the default representation of Java objects, i.e., examples of classes that do not implement toString(). Vectors are part of this group. I cannot see why you would like to…
-
1
votes1
answer665
viewsA: How to add counter to every if of my simple code
You haven’t explained exactly why you’re not succeeding, so I’ll tell you a little bit about the problems I’ve encountered and come up with a simple solution. The first thing is indentation. When…
-
2
votes1
answer2564
viewsA: Is it possible to modify any game?
Possible but not practical. You would need to use a decompiler to get Java code from APK. A possible deterrent is that the game is not only made in Java. It is very common among games made using…
-
1
votes1
answer3034
viewsA: Adding up positives in a range using only while
I think it has no simpler and readable form than using the function sum, since she was made for it. a = int(raw_input()) b = int(raw_input()) soma = 0 if a < b: soma = sum([numero for numero in…
-
3
votes1
answer211
viewsA: Sum of numbers smaller than n that are multiples of 3 or 5
Focus on the fact that the expected output is a single number: the sum. A simple way to solve it is to look at each candidate, from the smallest to the largest. If it fits the constraints, add it to…
algorithmanswered Pablo Almeida 5,060 -
2
votes3
answers5527
viewsA: List in Python with non-repeated values without using set function?
A way would be like this: a = [1, 2, 3] b = [3, 4, 5] c = [] for elemento in a: c.append(elemento) for elemento in b: if elemento not in c: c.append(elemento) What we’re doing is, for each element…
-
5
votes3
answers1779
viewsA: How not to repeat values in a Python list?
The appropriate collection to deal with elements that have no repetitions is the ensemble. You can create a Python set using the global function set. >>> a = [1, 2, 3] >>> b = [3,…
-
2
votes1
answer539
viewsA: Prevent Edittext from opening keyboard when I enter the layout
You can add to your declaration Activity in Manifest one of the following options: To always enter with the hidden keyboard android:windowSoftInputMode="stateHidden" To leave it as it is (that is,…
androidanswered Pablo Almeida 5,060 -
1
votes1
answer334
viewsA: User login with Webservice
From Android 3.0, network connections are no longer allowed in the thread main (also known as UI Thread). Network operations on that thread have the effect of freezing the graphical interface until…
-
1
votes4
answers3938
viewsA: How to open another Activity from a Navigation Drawer?
Supposing that the Activity that you want to open is called MinhaAtividade: Intent intent = new Intent(this, MinhaAtividade.class); startActivity(intent); this here is the context of Intent. I’m…
-
2
votes2
answers3331
viewsA: Check whether the attributes of an object are null in a less manual way
There’s no way. Think about it: how would Java know that its object is "null"? The null you are proposing is semantic, i.e., it depends on your interpretation of the object data. Let’s say that the…
javaanswered Pablo Almeida 5,060