Posts by ramaral • 44,197 points
1,060 posts
-
1
votes1
answer65
viewsA: How to put margin inside an ANDROID STUDIO text box
Then you have to apply a padding and not a margin. Margin - Puts the view in relation to the surrounding elements. Padding - Positions the view content relative to it The same shall apply to…
android-studioanswered ramaral 44,197 -
1
votes2
answers57
viewsA: As in a Lerner, assigned to more than one Spinner, know who called him?
The method onItemSelected receives, in the parameter Parent, the Spinner whose entry was selected. To know what that is Spinner just check your id . Anything like that: public void…
-
12
votes2
answers348
viewsQ: Should or should not Httpclient be used within a using block?
Reading this reply, a question relating to the use of using, I was curious about the following statement: In fact everyone uses HttpClient wrong, I even used and did not know everything, because I…
-
1
votes1
answer106
viewsA: Sqlite3 How to delete last records using ORDER BY
If you reverse the ordering order instead of the last will be the first ones you want to eliminate. If you do, you can then use the LIMIT clause to get only the 15 records you want to delete. DELETE…
-
2
votes1
answer40
viewsA: How to destroy a jobSchedule via Activity?
I don’t know if it’s Thread who stays alive after canceling Jobscheduler All indications are yes. Not only does Thread need to be stopped, but you need to cancel Timer. Note that a Jobscheduler…
-
0
votes1
answer51
viewsA: Listview repeats the last record inserted in Sqlite across the list
The reason all rows have the same value is that the class fields have been declared Static. A field Static has its value shared by all bodies. Thus, when it is changed, whatever the instance that…
-
2
votes1
answer61
viewsA: How to eliminate the pause between animations of an Animationset?
Just inform the Animationset that should use the same Interpolator in all animations: animSet = new AnimationSet(true); The delay, who noted, is due to the creation of a new Interpolator to manage…
-
1
votes1
answer169
viewsA: What does it mean to underline this section of the code?
If it’s not working as it should, it’s not for that reason. In this case, the underlined variable name indicates that it is a local variable final declared outside the anonymous class where it is…
-
2
votes3
answers99
viewsA: Return method asks return that has already been given
What’s wrong is missing one return. A method that requires a return has to have in all possible execution paths the corresponding return Case exemplary no for(foreach) entries are not executed, and…
-
3
votes1
answer81
viewsA: stopService() not for service
Will I be able to stop the service, but as it is linked to a thread to the main part, it will only actually stop when what is inside the thread ends? Yes, that’s exactly what happens. It is one…
-
6
votes2
answers128
viewsA: If abstract classes and interfaces cannot be instantiated, what is happening here?
Despite new ActionListener() seems to indicate that it is instantiating the interface, what is being done is to declare and at the same time implement and instantiate a class that implements that…
-
3
votes1
answer31
viewsA: When overriding a method should I call the super implementation before or after my code?
In most cases it makes no difference, it is best to always read the documentation of the method. The documentation of onPause() only refers to the obligation to call, does not say when. If in doubt,…
-
2
votes2
answers189
viewsA: Downgrade project version in android studio from 6.0 to 5.0
I developed a project in android studio on API 23: Android 6.0 (Marshmallow). No, the project was developed using API 28 as indicated in build.Gradle with compileSdkVersion 28. I wonder if there is…
-
2
votes1
answer32
viewsA: Repeated id’s in different xml layouts on Android
The method findViewById() just search for the id in the view hierarchy it belongs to, like this: in different xml’s no problem. In the same xml you can use but should avoid. There can be no…
-
3
votes1
answer77
viewsA: Set Variables by Java Constructor
Yes is right and desirable. Especially if they determine the valid state of the object. This is the case of the first example, in it are "requests" all values for the object to be created in a valid…
-
3
votes1
answer51
viewsA: Detect implicit Intent action when the Android Operating System changes the time manually
When the system date/time is changed a android.intent.action.TIME_SET. To intersect it, register a receiver on Androidmanifest.xml <receiver android:name=".TimeChangeReceiver">…
-
2
votes1
answer37
viewsA: With Constraintlayout no more match_parent?
Use/can use yes, because: Constraintlayout inherits from Viewgroup, which is the base class for all layout types. Any layout must have its dimensions defined. The value of the dimensions can be an…
-
1
votes2
answers911
viewsA: Fields with the same name in different tables
No, because the name of the column can be added the name of the table to distinguish it. When naming a column the concern should be to identify it/describe its content in the best possible way.…
-
3
votes1
answer138
viewsA: Why does my service overload the device?
Without being able to test it is not easy to know the true cause. However, analyzing the code available, I find several problems that may justify this behavior. The way it is, due to while(true){},…
-
4
votes1
answer213
viewsA: How to ignore a Serialization?
That attribute cannot be applied in properties. To apply you will need to turn the auto property into one with backing field and apply the attribute to backing field. [NonSerialized] private Socket…
-
2
votes1
answer128
viewsA: Tcpclient C# Windows Form how to close and open the same connection
The error is due to not having properly disconnected the previous connection and making a new connection using the same port. To close the connection use NetworkStream stream =…
-
2
votes2
answers72
viewsA: Know which values within the IN condition are not linked to the table
Cannot select something that does not exist in the table. What can be done is to have a table with all the letters and use SELECT letra FROM LetrasTodas WHERE letra NOT IN (SELECT letras FROM…
-
3
votes1
answer79
viewsA: Why is the class expected error?
float is a primitive type, has no methods. Methods belong to classes, hence the error .class expected. The method parseFloat() belongs to the class Float. Alter float V =…
-
0
votes2
answers146
viewsA: How to show all markers?
Create a Latlngbounds that includes all points. Use CameraUpdateFactory.newLatLngBounds(LatLngBounds bounds, int padding) to obtain a Cameraupdate that will cause the camera to display the…
-
1
votes1
answer104
viewsA: Why does the getter return null?
The user.getToken() is being used right after object instantiation user. Utilizador user = new Utilizador(); token = user.getToken(); As no value has been assigned to the field token user.getToken()…
-
3
votes1
answer57
viewsA: Edittext does not accept Keylistener
From the error it seems that the interface that Activity implements is not the one that the method setKeyListener() waiting. I don’t know if you’re changing the method or if you’re switching the…
-
1
votes1
answer137
viewsA: How to bring an application forward(from the background to foreground)?
The mechanism used on Android to indicate to the user that an application needs their attention are the notifications. The application launches the notification, the user when he understands reads…
-
4
votes1
answer122
views -
0
votes1
answer32
viewsA: I can’t send my App data to the database
Validation of the creation of the new user is done by checking whether the return of the method CriarUtilizadores() returns a value greater than zero. The way it is, the method always returns zero.…
-
1
votes1
answer46
views -
2
votes2
answers85
viewsA: Programmatically or in XML layout
What is best in programming depends on the context. The same approach may be better in one situation and not in another. The use of xml is in most situations, for being declarative, more efficient…
-
2
votes1
answer71
viewsA: How to hide part of a view?
Add a field to the Stickerbtn class to control whether Bitmap is drawn or not in the method onDraw(). private boolean drawControllerBitmap; // inicialize com true caso pretenda // que inicialmente…
-
2
votes2
answers144
viewsA: Inner Join Sqlite with Cursor on Android
In situations like this use the method public Cursor rawQuery (String sql, String[] selectionArgs) of the class Sqlitedatabase. The method returns a Cursor with the result of query passed to the…
-
1
votes1
answer49
viewsA: Why do I get null on onPostExecute?
The use of Asynctask, in this case, makes no sense, the processing done by the api Ion is already asynchronous. The result that comes to onPostExecute() is null because the line return retorno;, of…
-
3
votes1
answer80
viewsA: Listview returns only one Cursor item
For each entry on the cursor a new modelListprod should be added to the array Prod. View comments in code. public void lprod(SQLiteDatabase db){ ArrayList<modelListprod> prod = new…
-
1
votes1
answer122
viewsA: Variable "initializer is Redundant"
It is not the variable that is redundant. What’s redundant is starting it with zero. When declaring a variable of a numeric type it is automatically initialized with zero. Instead of var resultado=0…
-
0
votes1
answer65
viewsA: Update location from time to time when an application is running in the background
This has to do with limitations imposed by Android 8 to the execution of services on background. The solution is to use a foreground service(startForegroundService() instead of startService(), or a…
-
1
votes1
answer203
viewsA: Is it possible to use variables to set the size of a View?
Possible, but not in xml. You must use the Java object that represents that Imageview and its Layoutparams object. Get the object from your Imageview: final ImageView aSuaImageView =…
-
2
votes1
answer40
viewsA: How to limit Drag and Drop to certain views only?
In the method onDrag(), of your Ondraglistener implementation, check that the id of the received view is the one you want if it is not returned false: @Override public boolean onDrag(View v,…
-
4
votes2
answers82
viewsA: code decrease
If all these buttons are within the same layout, you can use the method findViewById() view class (this layout). int id = games.getBallId(); Button button = (Button)layout.findViewById(id);…
-
2
votes3
answers1314
viewsA: How to handle different date formats?
To get a string in the desired format, regardless of the device/user settings, do so: //Obtenha um Calendar com a data actual Calendar calendar = Calendar.getInstance(); // manipule a data como…
-
3
votes2
answers412
viewsA: Reuse code on multi-button onClick
I knew that: the same method can be associated with the multi-button click event? in an array different values can be saved, which can be accessed through an index? an object in the View class can…
-
4
votes4
answers587
viewsA: How to correctly send the value of a null variable in an INSERT?
Test if parametro2 is null and construct the proper insert. Anything like that: public async void InsertBanco(string parametro1, string parametro2) { var b = new BancoN(); SetBanco(b); if(parametro2…
-
5
votes2
answers68
viewsA: Query is not updating null values
The reason is that using comparison operators with NULL does not behave as expected. This can be checked as follows: WHERE nacionalidade NOT IN ('Americana', 'asdf', 'VENEZUELA', 'VENEZUELANO -…
-
3
votes1
answer95
viewsA: How to popular a parameter property with GET access
(...) where your access is GET? How does this method work internally? Instead of declaring the property in the "self-applied" form, implement it using a private field(backing field). Unlike the…
-
3
votes1
answer293
viewsA: How to create image animation by rotating, with decreasing speed, until it stops
The animation is achieved by varying a characteristic, in this case the rotation. How this characteristic varies over time is determined by Interpolator used. So, if you want there to be a…
-
1
votes2
answers169
viewsA: How to change attributes of all project Textviews at runtime?
It has 2 ways to change the fontFamily: Using the method setTypeface(): textView.setTypeface(Typeface.create("sans-serif-light", Typeface.NORMAL));…
-
7
votes1
answer98
viewsA: How to remove this shadow that appears when it reaches the "end" of the screen?
In xml, in the View statement, add android:overScrollMode="never". The same can be done in java using: myView.setOverScrollMode(View.OVER_SCROLL_NEVER); There are 3 modes: OVER_SCROLL_ALWAYS…
-
2
votes1
answer75
viewsA: Transform View into Bitmap without using buildDrawingCache()
Your code is a little "weird". Use the buildDrawingCache() but instead of taking advantage of the Bitmap it returns, creates a new one and uses a Canvas to fill it with the contents of view. Use…
-
3
votes1
answer89
viewsA: Create a protected directory in the device’s Storage
Android devices have two file storage areas: internal(Storage) and external(Sxternal). Files created in the internal area are always private, only the application that created them can access them.…