Posts by ramaral • 44,197 points
1,060 posts
-
1
votes1
answer328
viewsA: How to use SVG icon in Google Maps addMarker (Markeroptions) API Android
Write a method to get a Bitmapdescriptor private BitmapDescriptor getBitmapDescriptorFromVectorDrawable(int id) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { VectorDrawable…
-
4
votes1
answer101
viewsA: Method does not accept passing from null to parameter
You can pass null in all parameters other than primitive types. If you want to do the same in primitive type parameters, replace them with the respective classes: public String…
-
0
votes3
answers161
views -
1
votes1
answer163
viewsA: Create a Spinner from a fixed list with more than 1 field
You must first create an Arraypadrao instance and add it to Arraylist thus: ArrayList<ArrayPadrao> lista = new ArrayList<>(); lista.add(new ArrayPadrao(1, "aaa"));…
-
1
votes1
answer42
viewsA: How to get other values from the selected Spinner item than shown?
The information you can get from the selected Spinner item is only the one stored in the Arraylist that is used by the Adapter. As far as I can tell, Arraylist only guards the column name. Define a…
-
3
votes1
answer25
viewsA: How is it possible to declare an object without first instantiating it?
I think you are confusing declaring with initializing/assigning. On the line TextView txt = (TextView) findViewById (R.id.txt); the declaration is being made by TextView txt and at the same time,…
-
3
votes1
answer81
viewsA: Reference main class variable, in a @Override
The problem here is that the method variables have the same name as the Activity fields. Use NovoRegistro.this to access the Novoregistro object (your Activity): NovoRegistro.this.ano = ano;…
-
1
votes1
answer161
viewsA: Viewholder Pattern in an Activity
1) Would creating such a standard for Activity be bad practice? This standard should only be used when "recycling" of Views is required? The purpose of the Viewholder Standard is to avoid the…
-
1
votes1
answer51
viewsA: How to use Shape as drawable in imagespan
As the Shape is declared it has no dimensions. When it’s used as background or foreground other’s view no problem, since it fits the view dimension. When used as span this does not happen. So you…
-
2
votes2
answers71
viewsA: Replace part of string with drawable or image
Insert a Imagespan in a Spannablestring. Imagespan is built with the drawable to insert and Spannablestring with the text where it will be inserted. @Override protected void onCreate(Bundle…
-
5
votes1
answer327
viewsQ: Technology, Platform and Language, what are they and how do they relate?
Technology, Platform and Language are terms used to characterize various "aspects" of the "world of programming". What exactly does each of them refer to? What unites and/or separates them?…
-
1
votes1
answer309
viewsA: Validate form
I think you should change the method valid() in order to return false if one of validateNotNull() for false public boolean valid(){ boolean isValid = true; if(!validateNotNull(frua,"Preencha o campo…
-
1
votes1
answer70
viewsA: Change of themes through Java
To assign the theme to an Activity use the method setTheme(). Note that the new theme has to be assigned in the method onCreate() and before setContentView(). @Override protected void…
-
1
votes2
answers528
viewsA: Working with custom alertdialog layout
I suppose you want to get references to the views of the dialog layout when one of the buttons is clicked. Value passed to first method parameter onClick Onclicklistener, in this case identified as…
-
2
votes2
answers490
viewsA: Difference between Activity and Content
What you refer to are just file names of layout. A layout can be used by a Activity or not. Among others, they are used in Activities, Fragments, Listview’s or Recyclerview’s items. A file of layout…
-
2
votes1
answer1014
viewsA: Position button at the bottom of the layout
Contrary to popular belief, a Linearlayout, match_parent does not make it occupy all the Parent. The old name, fill_parent, in that sense, it was even worse. Put a view before the button so that it…
-
0
votes1
answer97
viewsA: Initialize element from one fragment into another
Use Activity as an intermediary between Fragments(fragment and fragmentB). Declare a method in the fragment, the one whose Textview you want to change: public void setText(String text){…
-
2
votes2
answers681
viewsA: Error in String to Double conversion
Why only on the mobile gives the error ? Gives error in one and not in the other because the decimal separator depends on the Locale defined in the device. In some cases it is ., in others is ,. I…
-
1
votes2
answers41
viewsA: Return Updated Android Date Time
If you want the method toString() return the value of dateString you have to overwrite it: public class DataHoraAtual { long date = System.currentTimeMillis(); SimpleDateFormat sdf = new…
-
2
votes2
answers182
viewsA: Nullpointerexception when obtaining latitude and longitude
The method getLastKnownLocation() can return null. This is more likely if you are using an emulator. The method just does not return null if any application has ever requested the location of the…
-
2
votes1
answer235
viewsA: Onclick on android not working
The object to be used by the Adapter to treat the onClick. I think it is your Activity that implements the interface Moviesadapter.Onitemclicked, if so, it should be assigned to the Adapter by the…
-
7
votes2
answers683
viewsA: How to run INSERT only if the record does not exist?
Can use INSERT OR IGNORE. To this end, the column(s) (s) concerned shall (m) be declared(s) as UNIQUE. When there is a violation of a restriction (Constraint) it is treated as indicated in Conflict…
-
1
votes2
answers81
viewsA: How to Capture UTC with an Android App
Use the class Timezone. TimeZone timeZone = TimeZone.getDefault(); String name = timeZone.getID(); The method getDefault() returns the Timezone the device is using. The method getID() returns your…
-
2
votes2
answers604
viewsA: How does firebase work for sending notifications?
It works exactly as you’re thinking: a service on your device maintains a connection to Google’s servers. The key difference is that this service serves multiple servers/clients, all those who have…
-
0
votes1
answer383
viewsA: Convert an Object to Arraylist<Visitor>
Do the cast of object for ArrayList<Visitante>. array = (ArrayList<Visitante>) objecto; If the object is not of the type indicated, an exception of the type ClassCastException…
-
2
votes2
answers107
viewsA: How to make this type of signature in C#?
The closest C# class is the Type class. Class is a generic class: Class<T>. The expression <? extends Teste> limits the type to those who inherit Test. The equivalent in C# is where T :…
-
0
votes2
answers162
viewsA: I can only solve dependencies by using'+' in Library versions
When using the support libraries, in those that are related to each other, you must use the same revision number. Preferably you should use the last revision, which on this date is version 27.0.2.…
-
3
votes1
answer490
viewsA: How to close the keyboard?
Implement the following method: private void hideSoftKeyboard() { InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Activity.INPUT_METHOD_SERVICE);…
-
0
votes2
answers155
viewsA: Change visibility of xml layout with the change of orientation of the device
The recommended approach to dealing with this need is to build a layout different for each orientation of the device. Android allows you to use configuration qualifiers to name resource folders so…
-
1
votes2
answers1102
viewsA: How to add an icon at each end of an Edittext?
Taking in your xml will be like this: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"…
-
1
votes1
answer129
viewsA: Data disappears while moving Recyclerview scroll with Firebase
Your code is a little confusing to give an answer using it. However, this type of problem occurs when in the onBindViewHolder() if you use one or more paths(if/Else) to do the bind. This is because…
-
7
votes1
answer6369
viewsA: How to build a SELECT on Sqlite?
Constructing dynamic SQL commands with concatenation does not always produce the expected/valid result. In this case, the applications are missing. They are necessary when using a string as value.…
-
2
votes1
answer185
viewsA: How to create a split between views?
The android:divider is a drawable. So you can look whatever you want. In this case, to get him to have margins, use a Insetdrawable: Divider.xml <?xml version="1.0" encoding="UTF-8"?>…
-
1
votes1
answer43
viewsA: The "code Completion" window has few drawable alternatives to insert
The options that appear are those corresponding to drawables that are in the folder res\drawables of its project. In fact, in older versions appeared all that his project had access to which, in my…
android-studioanswered ramaral 44,197 -
2
votes2
answers120
viewsA: Create a Generic Adapter
Yes it is possible. However you will have to write a Viewholder for each type of layout of the item, a Viewholderfactory and your Model will have to implement an interface. Viewholder is required to…
-
1
votes1
answer56
viewsA: How to create a non-circular geofence area?
In the form of a generic polygon. If the shape of a rectangle is sufficient use the class Latlngbounds To use, build a Latlngbounds informing Latlng of the lower left corner (Southwest) and Latlng…
-
2
votes1
answer24
viewsA: Problem using Putextra with a vector
What you’re putting in the extras is a double and not an array, valores[vetorEdits.length] is a double, the one that is stored in the index vetorEdits.length. I think I might be making a mistake on…
-
5
votes1
answer611
viewsA: Get user location without using GPS
GPS is not the only way to get the user’s location. It can be obtained by WI-FI or mobile network (antenna triangulation). However, its accuracy may be low for what you want. The API to get the…
-
1
votes1
answer1037
viewsA: access permission to android image gallery
Only you know what the application should do if the user denies access to "EXTERNAL_STORAGE". However, if the application depends on such authorization to function, what it should do is to present a…
-
1
votes3
answers135
viewsA: Edittext style texts - Underline in Zigzag
Use a Spannablestring and apply a Replacementspan: public class ZigZagUnderlineSpan extends ReplacementSpan{ private Paint linePaint; private int textMessureWidth; private float…
-
6
votes1
answer3429
viewsA: Use Bundle and/or only putExtra?
In the two examples you are using a Bundle. The difference is that in the first example it is you who create it, while in the second it is created internment by the Intent class. The method…
-
2
votes1
answer63
viewsA: Problem with Fragment
Activity, to which this Fragment is associated, must implement the interface Onfragmentinteractionlistener. That is, you must declare Activity in this way: public class MainActivity extends…
-
2
votes3
answers1206
viewsA: Preview Android stopped working after update
The upgrade system does its job very well. Follow the instructions indicated by it and usually everything will be fine(in my case always ran). Android Studio relies on other "tools" to work, namely…
-
0
votes1
answer45
viewsA: Error inserting data into Sqlite : java.lang.Illegalstateexception: getDatabase called recursively
You are getting a call to the bank without closing the previous link. In the method _insert(SQLiteDatabase dbsql) eliminate the line dbsql = this.getWritableDatabase(); dbsql already has a reference…
-
6
votes3
answers75
viewsA: Why in the second example (unlike the first) the result is concatenated and not summed?
Java, when it finds an expression like "String" + tipo primitivo, uses the method toString() of the primitive type to obtain the string which represents it and then concatenate it with the previous…
-
1
votes2
answers749
viewsA: How to use Android Studio Interface Editor only?
To which a file(layout) xml is opened in the layouts from Android Studio it has to be inside the folder res/layout of the project. It’s a "little weird" what you want, yet you can do the following:…
-
2
votes1
answer785
viewsA: Change the color of a Button that already has an assigned Background
If minSdkVersion >= 21 use android:backgroundTint For lower versions, change the color of the solid for #FFFFFF and use the following code to put the color you want, button =…
-
2
votes3
answers5991
viewsA: Convert number to string to two decimal places
Since it does not need to round, simply use the simple manipulation of the string: var valor = "12,126456"; var commaPosition = valor.IndexOf(",", StringComparison.Ordinal); var result =…
-
3
votes2
answers441
viewsA: Should I cover private methods in unit testing?
In principle it should not be necessary to test them. A private method, if it exists, is to be called. This will be used directly or indirectly by a public method. If the tests you implement cover…
-
2
votes1
answer560
viewsA: Bigdecimal - Numberformatexception Error
The error indicates that you are trying to create a Bigdecimal with an invalid value, possibly a string empty. The problem is how the test is being done in if’s. Substitute…