Posts by Pablo Almeida • 5,060 points
155 posts
-
0
votes2
answers231
viewsA: Highlight main words of a text in order of a ready list
You can do it using two for: principais_palavras = "bom dia vamos lindo" base = """Bom dia que dia lindo vamos embora vamos chutar o dia""" lista_prioritaria = principais_palavras.lower().split(" ")…
pythonanswered Pablo Almeida 5,060 -
0
votes1
answer59
viewsA: How to define a subclass of an abstract class so that it is concrete
You need to implement all functions purely virtual (defined as "virtual nome_da_duncao(...) = 0" ) of the hierarchy. How Arvore is descended from Vegetal, she needs to implement funcC. But how…
-
2
votes2
answers99
viewsA: Why split this operation into two cause result changes?
What happens is that in the expression a, b = b, a + b, the value of a + b is calculated before the value of a be amended (to b). Example: a = 3 b = 5 a, b = b, a + b a => 5 b => 8 When you do…
-
1
votes1
answer145
viewsA: Am I throwing correctly?
This will not work because the method you are calling is asynchronous. This exception would be thrown to another thread, where the network call is taking place, and it wouldn’t work anyway. This DAO…
-
1
votes4
answers361
viewsA: Comparison between random number and typed number never says it’s right, even though the numbers are equal
When you do if n == (randint): you are comparing the n with randint, which is a function and not the selected value (note that functions are objects in Python). This comparison will always be…
-
2
votes1
answer49
viewsA: How do I kill a websocket?
According to the class Javadoc Websocketserver it seems to me that you are using, just use the method stop on your server. The problem is, when you do new ServidorExt(8080).start();, you are…
-
2
votes1
answer174
viewsA: How to use Appcompatactivity functions within a Fragment?
getSystemService is a method of Context. Activity is a Context, so you can use to call directly when you’re inside a Activity. Fragment is not a Context, then you need to pick up an object Context…
-
2
votes1
answer478
viewsA: Passing string to team
Use the class datetime of the datetime package to create a date with time information: from datetime import datetime dataComHora1 = datetime(2018, 1, 29, 22, 35, 12) You can do mathematical…
-
0
votes1
answer50
viewsA: Difficulties in making the G2 library work in C code
The syntax wrld->(sw->xdim) is invalid. The compiler is expecting a function name before the parentheses because he thinks that sw->xdim is the argument of a function call that comes after…
canswered Pablo Almeida 5,060 -
5
votes1
answer201
viewsA: Toolbar with two different colors
The name of this effect is Dégradé (gradient) or Gradient (gradient). To use a gradient at the bottom of your bar, just create an XML with its data in the Drawable folder and use it as background…
-
3
votes1
answer27
viewsA: Buttons of a Linearlayout are getting giant
Your problem is you’re giving layout_weight 1 for all buttons. This makes them all try to occupy their father’s full space, and end up with a third each. As their father is occupying the entire…
-
0
votes2
answers808
viewsA: Figure out the file format without extension
You can call the Trid through a system command inside Java. It already has the option to already rename the files to you by adding the extension. Note that Trid has an executable for each operating…
javaanswered Pablo Almeida 5,060 -
0
votes1
answer132
viewsA: How to initialize the components of a layout in the onCreate of a Fragment?
You need to inflate the fragment layout in the method onCreateView. Example: @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View…
-
4
votes1
answer1410
viewsA: How do I run an algorithm when the user stops touching the screen?
That’s not what Onlongclicklistener’s for. It is for all steps that form a long click event (the one that is usually used to bring up the context menu). You need to go to a lower level-use the…
-
1
votes1
answer43
viewsA: Android - How to identify exceptions released on mobile phones?
The Crashlytics aggregates the errors that occur in all devices in a web interface. It is widely used for this. In the Google Play dashboard you also have access to reports sent by users of your…
androidanswered Pablo Almeida 5,060 -
2
votes1
answer70
viewsA: How to call a new Activity through a conditional structure that tests the connection?
Your problem is that your method isOnline() does not work. It always returns true. Try this one: public static boolean isOnline() { ConnectivityManager cm = (ConnectivityManager)…
-
2
votes4
answers3854
viewsA: findViewById no Kotlin
This is happening because you’re forcing the kind of findViewById when it does as TextView. Since API 26, this is no longer necessary-- the type is automatically inferred for you. So you can do it…
-
1
votes1
answer407
viewsA: Duplicate focus when using requestFocus in an Edittext
Trade it for something like this: public class MainActivity extends AppCompatActivity { EditText numero, texto; @Override protected void onCreate(Bundle savedInstanceState) {…
androidanswered Pablo Almeida 5,060 -
1
votes2
answers1428
viewsA: Open a new Activity from within a Fragment
Inside the event that will open the new screen (button, for example), you will put something like this: Intent abrirOutraActivity = new Intent(getActivity(), OutraActivity.class);…
-
1
votes3
answers138
viewsA: In structures (struct) is it necessary to use getters and setters or only in classes (class)?
It is not required in either, but by default in structs, the attributes are public. This means that if you have a class and wants to access one of the attributes of one of its copies from the…
-
0
votes1
answer32
viewsA: I cannot update the value of a String by clicking on a certain button
In your HTML, you missed giving the id "screen" to input: <input id="tela" type="text" class="form-control" placeholder=""> In your Javascript, you had placed a comma in place of the key lock…
-
1
votes1
answer1100
viewsA: first-fit, best-fit and Worst-fit python
Expanding on Leonardo’s idea: Save the position of free space you are considering. For example, your first free space is at position 1. There you have two variables-let’s say, posicaoEmConsideracao…
-
2
votes1
answer141
viewsA: Appear 1.0k instead of number 1000 and so on
public class Main { public static void main(String args[]) { System.out.println(abreviarComK(1000)); System.out.println(abreviarComK(2000)); System.out.println(abreviarComK(10000));…
javaanswered Pablo Almeida 5,060 -
1
votes1
answer40
viewsA: How to limit Firebase Storage downloads to a certain maximum amount per user time period?
You can have a list of users (in your case, ad ids) and, associated with each user, a list of timestamps of the moments at which each download was made. Before starting a download, take the last 20…
-
0
votes1
answer142
viewsA: Even using fflush, the fscanf function is not working
You’re probably hoping that fflush(stdin) clear your input stream of any characters left in it from the last input, but the fflush was made to clean only outflow. The behavior of fflush when it…
canswered Pablo Almeida 5,060 -
-1
votes1
answer395
viewsA: Substitute function for jQuery’s . error() function
According to the official documentation: From jQuery 1.8, the method .error() is depreciated. Use .on( "error", tratador) to attach event handlers to error event. That is, change your code to:…
-
9
votes4
answers229
viewsA: Is overloading methods less performatic?
No. The performance should be the same. The method to be called is decided at the time of compilation, based on the types of arguments, since these are already known at that time. You can imagine…
-
14
votes4
answers359
viewsA: Output a C code with pointers
p appears as the value 6487628. This is the actual value stored in p, which is the address of i. *p+2, due to the precedence of operators, should be interpreted as (*p)+2. *p returns the value…
-
2
votes1
answer1207
viewsA: How to calculate the n-th root of a number in C?
Try it like this: double funcao1(int y,int z){ double k; k = pow(y,1.0/z); return(k); } Or better yet: double raiz(int radicando, int indice){ return pow(radicando, 1.0/indice); } What has changed:…
canswered Pablo Almeida 5,060 -
3
votes1
answer2438
viewsA: How to use C’s Pow function?
You need to pass the parameter -lm for gcc to enable the link to the mathematical library. Stay like this: gcc nome_do_arquivo.c -o nome_do_arquivo.exe -lm…
canswered Pablo Almeida 5,060 -
2
votes1
answer167
viewsA: `Uncaught Referenceerror: floor is not defined` when trying to use floor and Random to choose an item from an array randomly
floor and random are object methods Math. You need to do Math.floor and Math.random. Besides, you were passing the length as a parameter for the random. It is right to multiply. So change this: var…
-
0
votes1
answer828
viewsA: How to update the value of a variable within a callback?
You can’t use returns for this. When the function sendMessage returns, the function you associated with chat.message may not even have run yet, because all this is asynchronous. There where you did…
-
3
votes1
answer3275
viewsA: Check if the input is an integer
The problem here is that you’re using scanf, who’s interpreting the entry as an indepentende number of what’s really there. What you can do is read your input as text and then use the function…
-
1
votes1
answer131
viewsA: How to open different web pages using while
For each open has a sleep correspondent. This already gives you a clue that your loop cannot be composed of several open the way it is, and yes only one. How will you have just one open, you need to…
-
0
votes3
answers746
viewsA: Toast with specific duration
Toasts have only two possible durations: Toast.LENGTH_SHORT and Toast.LENGTH_LONG. These values are treated as flags and not as durations. It is not possible to manually choose an exact duration…
-
1
votes1
answer1003
viewsA: Most suitable mapping of JSON to Java object
Use maps when the key is always the same (always id, name, ingredients) doesn’t make much sense. The ideal, from the point of view of leaving your code more expressive, is to have a class for each…
-
19
votes7
answers49622
viewsA: How to add elements from a list and return the result as an integer?
If this is not a learning exercise, don’t re-invent the wheel. Use the function sum, which is exactly what it’s for. soma = sum([1, 2, 3]) > 6 If you really need to redo the sum function, try…
pythonanswered Pablo Almeida 5,060 -
0
votes4
answers874
viewsA: Manipulating JS odds when using Math.Random()?
It would be more interesting for you to say which problem exactly you want to solve. But, according to your example, you can first make a draw to determine whether the number you want is even or…
-
3
votes1
answer88
viewsA: Close Dialog opened inside the Recyclerview Adapter
Do not create dialogues within others Views (such as the RecyclerView). Let the Activity take care to display this dialogue and dispense it when the time comes, while the RecyclerView just passes…
-
0
votes1
answer1381
viewsA: Error: A problem occurred Configuring root project 'Meuprojeto'
Take this part of the build.Radle corresponding to the entire project (the first file you put in): // Add to the bottom of the file apply plugin: 'com.google.gms.google-services' So it stays that…
-
7
votes1
answer7563
viewsA: Lightweight and stable alternative to Android Studio
If your project has to be done in Java, you have no choice. In theory, you could do in Eclipse, but get started an Android project in Eclipse today is a maintenance suicide, since the Android…
-
2
votes3
answers3930
viewsA: Difference between setImageResource and setImageDrawable
The way you’re doing, none, because you’re converting a Source into a Drawable. But Drawables don’t have to come from Resources: they can come from local files on the device, the Internet, an XML,…
-
3
votes3
answers189
viewsA: Is it better to have a kind of exception for each case or a more general exception?
The decision whether it is necessary to create a lot of different types of exception or create one that covers all is not as simple a decision as "see if it has a lot". This is an area where you…
-
2
votes1
answer486
viewsA: How to get the Android version number?
You can use the constant Build.VERSION.RELEASE. An example of use for your case would be: mWebView.getSettings().setUserAgentString("Mozilla/5.0 (Linux; App Mobile Android " + Build.VERSION.RELEASE…
-
2
votes1
answer230
viewsA: Show emoticons with independent keyboard button
Me looks like that nay. But you can try a library of emojis that resembles much the emoji input from the keyboard to achieve that goal.…
-
2
votes1
answer384
viewsA: Increment a numeric string in 1
Use this function: def incrementarStringNumericaEmUm(stringNumerica): qtdDigitosComZeros = len(stringNumerica) originalComoNumero = int(stringNumerica) qtdDigitosSemZeros =…
-
5
votes2
answers1540
viewsA: Swap a variable from True to False and vice versa
A simple variavel = !variavel; inside your Istener solves your problem.
-
1
votes1
answer48
viewsA: How to place the Run/Debug/etc. buttons on the left side of the bar?
Click on View -> Toolbar. Okay, the other buttons will appear and these will be placed on the left side.
-
5
votes2
answers48
viewsA: New instance overwrites old values
This here... class Signal: point = None view = { "x": None, "y": None, } ... # fim da classe ...You don’t do what you think you do. Declaring variables at the top of the class in this way causes…
-
0
votes2
answers307
viewsA: Loop in time interval
You never change the state of inicio nor fim in the body of his while, then the value of inicio.after(fim) will never change, causing the endless loop.…