Posts by António Macave • 486 points
46 posts
-
0
votes3
answers25
viewsA: How to create a button to add one more to the editText value?
If your idea is to update the values You need to do the findViewById()` of Edittext to pick up your reference. And you will make the updates in this Edittext. public class Linha extends…
-
0
votes3
answers1432
viewsA: Convert Double to Integer
You can use the NumberFormat and in the onCreate() you initialize and configure it and then use this object to format the numbers. For example: public class MainActivity extends AppCompatActivity {…
-
3
votes1
answer82
viewsA: Implementation of the Life Cycle of an Activity
Basically, Activity’s lifecycle methods have their moments of execution. See below: onCreate(): It is the first function to be executed in an Activity. It is usually responsible for loading XML…
-
0
votes1
answer48
viewsA: Android Studio says some classes have not been used and almost all code is red
Problem solved! Since the dependencies were already there at Gradle, I had to remove them and re-enter them and do the Sync Project. And so it was successfully corrected!!!
android-studioanswered António Macave 486 -
0
votes1
answer48
viewsQ: Android Studio says some classes have not been used and almost all code is red
I was tweaking the code a little bit, when all of a sudden it looked like this that you can see in the image below. I have no idea what caused it, I tried to do the Clean and the Rebuild and…
android-studioasked António Macave 486 -
3
votes1
answer1495
viewsA: How to resolve adb.exe start-server' failed -- run Manually if necessary
I fixed the mistake. There was a certain service (traccar) that was running on my PC. All I had to do was restart it and close the lawsuits adb.exe, and Android Studio returned to work normally.…
-
2
votes2
answers51
viewsA: How to modify the last item of a sequence in Java?
You can create a String to add the "V" to it and then add the dot. Thus: N = ler.nextInt(); String str = ""; for(i = 0; i < N; i++){ srt = str.append("V "); System.out.print("V "); } str =…
javaanswered António Macave 486 -
0
votes2
answers604
viewsA: Problems receiving money as input in edittext
Set Edittext in XML: <EditText android:id="@+id/edt" android:layout_width="wrap_content" android:layout_height="wrap_content" android:inputType="double" /> And in Java use a Numberformat…
-
1
votes1
answer1495
viewsQ: How to resolve adb.exe start-server' failed -- run Manually if necessary
I’m having the mistake: Unable to run 'adb': null 16:08 'C: Desktop Users PI SDK Platform-tools adb.exe start-server' failed -- run Manually if necessary By pressing the run button Android Studio…
-
0
votes1
answer23
viewsA: How to make the menuItem (Radiobutton) be selected according to the type of map?
I figured it out. Just create a method to check if the map is null and configure the menu later. public boolean isMapNull() { if (map != null) { return false; } else { return true; } } And put it on…
-
0
votes1
answer298
viewsA: close alertdialog open with inflate
You can do the following: Open the dialog box, and when clicking the OK button of the dialog box pick the text entered, put it in such String and close the box. Create a Listener for the dialog box…
-
-1
votes2
answers124
viewsA: Tablayout under the actionbar
Before, you have to define the type of layout in which these elements will be inserted. Try to put them inside a Relativelayout and indicate to Viewpager that it should be under Tablayout using…
androidanswered António Macave 486 -
0
votes1
answer25
viewsA: Android - Change components of a Dialog
First create an element in the Java class and then retrieve it from the Dialog. For example: public void dialogClick() { Dialog dialog = new Dialog(); dialog.setContextView(R.layout.resource);…
-
0
votes1
answer208
viewsQ: How to make a View overlap?
I have this XML: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"…
-
0
votes1
answer23
viewsQ: How to make the menuItem (Radiobutton) be selected according to the type of map?
I have a Fragment that misses every time I start it. It generates the following error: java.lang.NullPointerException: Attempt to invoke virtual method 'int…
-
1
votes0
answers299
viewsQ: How to add a Menu in a single Fragment?
I have 3 Fragments and all of them in one Activity Mom. I want the following menu: <?xml version="1.0" encoding="utf-8"?> <menu…
-
0
votes2
answers78
viewsA: Create frame for item list
If you want to customize Listview, I recommend this tutorial there: https://androiddevbr.wordpress.com/2013/12/09/tudo-sobre-listview/ They explain everything perfectly! I hope I’ve helped!…
-
1
votes2
answers437
viewsA: How to place Mapactivity in a Fragment
Thanks to everyone I’ve already made it! It was very simple, just catch this stretch: SupportMapFragment mapFragment = (SupportMapFragment) getFragmentManager() .findFragmentById(R.id.map_fragment);…
-
0
votes2
answers437
viewsQ: How to place Mapactivity in a Fragment
It is so, I have a Mapactivity, but I would like the map to be in a Fragment. How can I do this? I created a Fragment, implemented the methods of Mapactivity created by Android Studio, but I come…
-
4
votes1
answer678
viewsQ: Error while recovering data from Sqlite
I’m starting to work with database and I’m already in trouble. I ask for a hand! Well, I have a database, apparently, there’s no mistake in adding data to it. I have a Dbhelper class that inherits…
-
1
votes1
answer272
viewsQ: I can’t get some strings from the strings.xml
I want to get a String that is in the strings.xml file, but always gives the following error: java.lang.RuntimeException: Unable to instantiate activity…
-
0
votes2
answers338
viewsA: How to create project installation done on android studio
No, you don’t need to put it in the Play Store. Just do the following: Take the phone you would like to install and activate the USB debugging (USB debug) option that you usually find in Settings…
-
0
votes1
answer39
viewsQ: Error when customizing Infowindowadapter on Google Map?
I have this XML file: ?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"…
-
1
votes2
answers206
viewsA: What is this for? requestWindowFeature(Window.FEATURE_NO_TITLE);
I usually use this when I want to create a custom Alertdialog. Then, this code to remove that title bar. Because if I don’t add that code, and the title bar gets the white background.
androidanswered António Macave 486 -
1
votes2
answers96
viewsA: Change language in the app and stay changed
Instead of the database, I think you could use Sharedpreferences. It uses the same logic, and is most recommended for these effects!
-
-1
votes3
answers10606
viewsA: Convert object to String?
You can use the String.valueOf(int) For example: int par = 2; String dois = String.valueOf(par);
-
-1
votes3
answers705
viewsA: Pass parameter to the second Activity
When creating Intent do so: Intent i = new Intent(v.getContext(), Classe_Tela2.class); i.putExtra("soma", soma); startActivity(i); And on Monday, do the following: Bundle receptor =…
androidanswered António Macave 486 -
-2
votes3
answers705
viewsA: Pass parameter to the second Activity
In Java, "value is different from Value" and "Value is different from VALUE" . On that line where you declare the sum variable, you put Double, try to put double. Type: *double* soma = valor1 +…
androidanswered António Macave 486 -
1
votes1
answer122
viewsQ: Map no longer works
I’m developing an application that used the Google Maps API. It was working normally, until I upgraded Android Studio from 2.1 to 2.2 and from there to here, it stopped working. What do I do to use…
-
1
votes5
answers1896
viewsA: Change Button Background
First create the shapes: Shape of Button (normal): <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android"> <gradient…
-
3
votes1
answer177
viewsQ: How to remove a Custom Dialog title?
I have this Custom Dialog And I’d like to know how to take that part of the title because in this case, it’s unnecessary. Code private void acertou() { final Dialog certo = new Dialog(this);…
-
0
votes0
answers281
viewsQ: Error when building a project in Android Studio
I have a project that was working normally, but yesterday I had to install Windows on my computer. And today I open the project and when I try to compile, I get this message: Error:(1, 1) error:…
-
3
votes1
answer216
viewsA: In an Activity, first open the onCreate method or class constructor?
Think like this, if a constructor is the first "method" to be executed, before the others (even if there is the main method, in the case of JAVA), then obviously the constructor will be executed…
-
2
votes2
answers427
viewsA: How to remove the Appcompat error from the app?
I’ve been through this problem, and it was not long ago. I tried everything,took a look even on Youtube. And I think there’s no way, so I ended up migrating to Android Studio. I believe that the…
-
0
votes1
answer295
viewsQ: Error generating signed APK
So, I’m developing an app where I want to use Google Maps, but when I try to generate the signed APK I get 2 (two) errors: Error:The number of method References in a . Dex file cannot exceed 64K.…
-
0
votes1
answer113
viewsA: Count the number of notes
To show the number of objects in the array (which in this case is the number of notes), you use length. Example: System.out.println(numeroDeNotas.length);
javaanswered António Macave 486 -
-1
votes2
answers329
viewsA: How to transform attributes into properties?
In Java it’s like this: public class Pessoa { private String nome; private int idade; public String getNome() { return nome; } public int getIdade() { return idade; } public void setNome(String…
-
0
votes1
answer1344
viewsQ: How to pick up the text from a button?
So, I have a question and answer game. Each question has 4 answers (placed on button labels). How do I get the text from the button clicked to compare to a String?
-
1
votes6
answers3996
viewsA: Check if Edittext is empty
You can do it like this: if (edt1.getText().toString().isEmpty()) { //Informar que o campo 1 está vazio. }
-
0
votes7
answers10560
viewsA: How to test if an Edittext is empty?
You can use the following: if (meuEditText.getText().toString().isEmpty()) { //faça tal... }
-
0
votes1
answer43
viewsQ: I get many errors in Android Studio when wanting to compile my project
There are many mistakes and I don’t even understand why. Please help.…
-
1
votes2
answers459
viewsA: Edittext without Focus by Activity
You can do this in the code itself by doing the following: EditText edt = (EditText) findViewById(R.id.edt); edt.setFocusable(false);
-
0
votes1
answer1321
viewsQ: How to identify the button that was clicked?
I have several buttons and I would like to compare the text of the button clicked with a variable of type String. That without using it: if (evento.getSource() == botaoXl) { // Fazer isto... } else…
-
1
votes4
answers1482
viewsA: How to change the color of the text in a Jtextpane?
If you only want to change the color of the text, do so: textPane.setForeground(Color.RED); And if you want to change the background color (background), do so: textPane.setBackground(Color.BLACK);…
-
0
votes4
answers602
viewsA: How can I replace "String.isEmpty()" in Java?
It may be so: if (str.equals("") { //commands here }
-
0
votes1
answer82
viewsA: Layout is not adapting (XML)
Put a Scrollview in your layout. Ex: blá blá blá... < /LinearLayout>