Posts by ramaral • 44,197 points
1,060 posts
-
5
votes2
answers2323
viewsA: Error "is not an enclosing class"
In this situation the error "not an enclosing class" is due to incorrect use of this. this, within an instance or constructor method, refers to the current object. When using MainActivity.this is…
-
3
votes1
answer92
viewsA: I played this style in drawable to have edge in my Edittext, it worked but I didn’t understand anything of it
You’re right to wonder why you have 3 items. In fact one of them is the extra. One layer-list, as the name suggests, is a list of layers, in this case of Drawables. Each of the Drawables is drawn on…
-
17
votes1
answer3670
viewsA: What is savedInstanceState?
savedInstanceState is a method parameter onCreate() which receives an argument of the type Bundle. It is used by the system to, when recreating an Activity, allow restore state it had at the time it…
-
2
votes2
answers58
viewsA: Linearlayout dimensions, defined in java, do not maintain proportionality between resolutions
The problem is that height and width of Layoutparams, when set via java, are values in pixels. In order for the dimensions to remain consistent between different screen resolutions you should think…
-
6
votes2
answers336
viewsA: How to eliminate the space left by invisible views on the screen?
The visibility of a view can have three states: Visible - the view is visible on the screen. Invisible - the view is not visible but takes up space. Gone - the view is not visible and does not take…
-
1
votes1
answer335
viewsA: WPF Xaml Stringformat
In order for the string resulting from the formatting to have the decimals as you want it is necessary that the source value, in this case PendenciaValorFator, represents that value to those decimal…
-
1
votes2
answers664
viewsA: Difficulty with Permission Location Android
The difficulty is not in using permissions but in understanding what the keyword represents this. Activitycompat.checkSelfPermission(Context, String) receives in the first parameter an object of the…
-
3
votes1
answer2307
viewsA: How to format text in a Textview?
It is possible to use some of the tags HTML to format text used in a Textview. They can be used in a String Resource or in Java using one of the methods fromHTML() class Html String Resource…
-
4
votes3
answers3930
viewsA: Difference between setImageResource and setImageDrawable
The purpose of the two methods is the same: to assign the content to the Imageview. The difference is only in the type that each of the methods receives. setImageDrawable(Drawable drawable) -…
-
2
votes2
answers69
viewsA: How to open a project directly from the explorer
Unable to open an Android Studio "project" via File Explorer. Android Studio, unlike other IDE’s, does not create a "project file". If you don’t want the previous project to be opened by Android…
-
2
votes1
answer134
viewsA: How to restart a service to call the oncreate again?
The logic of the task a Service performs should not be placed in the onCreate(). The responsibility of onCreate() is to initialize the Service, nothing more. Thus, all this logic should be placed in…
-
2
votes1
answer73
viewsA: Instant Run message on Androidstudio
The message indicates that you have not installed the emulator/device API version chosen to run the application. In your case you chose an emulator/device with Android 5.1 (Lollipop), for Instantrun…
-
2
votes2
answers949
viewsA: What is the best way to pass a context to a nested class?
This has nothing to do with the way the context is past. The reason for the error is that it is not allowed to access objects that use UI, as is the case Toast, in a Thread other than the…
-
3
votes1
answer79
viewsA: I’m in error of Apostrophe not preceded by
In Android apostrophe(') is one of the characters that when used in Resources of the string type, must be inserted into a escape sequence or, alternatively, put the whole string in quotes("). In…
-
5
votes1
answer1057
viewsA: How to detect if the system supports hardware acceleration?
Hardware acceleration is available with Android 3.0 (API level 11). From Android 4.0(API level 14) it is enabled by default. Hardware acceleration can be controlled at the following levels:…
-
3
votes1
answer448
viewsA: How to use the same onClickListener in more than one View?
Has three possibilities: Declare a class that implements the interface View.Onclicklistener private class ClickListener implements View.OnClickListener { @Override public void onClick(View v) {…
-
5
votes2
answers1234
viewsA: Compare Two List
You can use the method equals() of the List if over-write the method equals() class Comments to indicate when two objects Comets are the same: @Override public boolean equals(Object o) { // verifica…
-
4
votes1
answer585
viewsA: How do I get Timepickerdialog to start with the current time?
You can specify the initial time and minute at the time of construction of the object Timepickerdialog. See the statement of builder: TimePickerDialog (Context context,…
-
2
votes2
answers132
viewsA: How to get information from Satellites through Locationservices
Not that I know of. The Locationservices replaces the Location Manager in several things but as far as that information is concerned it continues to be obtained through him. For applications that…
-
20
votes2
answers319
viewsA: Why are the other types of variables not replaced by Dynamic in C#?
One of the characteristics of the C# language is to be static typing, this ensures that each type is used only where it is expected. The guy Dynamic was created to simplify access to COM Apis. In…
-
4
votes3
answers969
viewsA: Creating an Activity and calling multiple Layouts can be harmful?
Yes, it is "harmful" and should not use. From the outset because it goes against the first principle of SOLID: a class must have a single responsibility. The name Activity(Activity) itself suggests…
-
5
votes2
answers6930
viewsA: Why doesn’t my image appear when running the app?
I tested its layout and it was correctly presented. The only thing I see that might be creating the problem is the use of the attribute app:srcCompat. Despite the main reason for the existence of…
-
2
votes1
answer91
viewsA: Use Datepicker in an Activity
There is the Datepicker which can be used as a view normal in any layout. To be displayed as it is in the image of the question you must use the attributes datePickerMode and calendarViewShown with…
-
12
votes4
answers14893
viewsA: Advantage and advantage between onClick and setOnClickListener
I find only one advantage in each of them which, in turn, represent a disadvantage in relation to the other. setOnClickListener(). Upside. Allows reuse of existing code. If you implement the…
-
5
votes1
answer1320
viewsA: Translate date long format from English to Portuguese
Date presentation format differs from country/language to country/language. To get the format for the desired country/language you must inform yourself to Simpledateformat its Locale. Use this…
-
4
votes2
answers194
viewsA: Nullpointerexception error using Boolean type
The field saved is declared to be of the type Boolean. Unlike the primitive type Boolean(b lower case), which is automatically initialized with the value false, the guy Boolean(Capital B) is null,…
-
3
votes1
answer116
viewsA: How to change the background color of Popupmenu?
The type of Resource that Popupmenu expects how Background is an image, more exactly a 9-Patch bitmap, and not a Color. After creating the 9-Patch bitmap you want to use put it in the folder…
-
1
votes1
answer53
viewsA: Pause an Asynctask until a task is completed
The fact that both the method trazer() and listar() receive a Callback gives idea that they are asynchronous. If so it is not necessary to use a Asynctask. Since you need the first object to "bring"…
-
5
votes3
answers318
views -
16
votes2
answers3271
viewsA: What is the difference between Listview and Recyclerview?
What a difference between Listview and Recyclerview on Android? There are two differences between the Listview and the Recyclerview: To Recyclerview is agnostic in relation to where the views are…
-
12
votes2
answers8134
viewsA: What is the right approach to get the click/position in Recyclerview?
It is always difficult to say what the "right approach" is, it can be better in one case and worse in others. The onClickListener are assigned to the view. Who is responsible for providing view at…
-
1
votes2
answers337
viewsA: V4 and V7 on Android
What would this V4 and V7 be? Although the current documentation states that both are to be used as of version 2.3 (API 9), the reason for the notation Vnn was to indicate which version of the SDK…
-
7
votes1
answer41
viewsA: Not converting INTEGER to String
See the cause of the error: Caused by: java.lang.NumberFormatException: Invalid int: " 2" There is a space before the number. Before converting use the method Trim() of the string class to delete…
-
2
votes2
answers161
viewsA: How to round double values returned by Interface Location
Rounding up values may not be the best option. What is normally used in this situation is the API Geofencingclient. It allows circular zones to be defined from a location and radius. These zones are…
-
2
votes1
answer44
viewsA: Download Async + Copy = Copying image 0 bytes
Any code you place after await Task.WhenAll(urlTasks);will be executed when all task finished. You can then make a copy of all downloaded files: ..... ..... await Task.WhenAll(urlTasks); foreach…
-
2
votes1
answer185
viewsA: Value attached to variable within setOnClickListener is not being considered
The code that is in Listener is only executed when an image is clicked. So when the execution reaches the line if (posicao==1) the value of the variable posicao is zero. What you should do is have…
-
3
votes2
answers2085
viewsA: Radio button selection return in C#
The code always returns 1, when there is none Radiobutton Checked, because there is only one control within the control c. If there were 2 it would return 2, etc. Note that the i is incremented in…
-
1
votes1
answer216
viewsA: Error "Please configure your build for Vectordrawablecompat"
Error indicates that you should configure the build.gradle in order to deal with VectorDrawableCompat. This is due to the versions of Android Studio, Gradle Plugin and appcompat-v7 who are using.…
-
6
votes1
answer70
viewsA: Check if android is in energy saving
From version 21(Lollipop) it is possible to check the power save mode through the method isPowerSaveMode() class Powermanager (which deals with the control issues of the device’s energy state), it…
-
2
votes1
answer2946
views -
11
votes2
answers3434
viewsA: What’s the difference between Gravity and layout_gravity on Android?
The difference is what it refers to Gravity. android:gravity - Position the content of view in relation to her. android:layout_gravity - Positions the view in regard to the layout containing. This…
-
1
votes1
answer1006
viewsA: Bug with.google.android.gms in ':app:processDebugGoogleServices'
This error informs that there is a conflict between versions of google-services plugin and the api’s com.google.android.gms. You are using version 9.4.0 of the api s com.google.firebase at the same…
-
0
votes1
answer49
viewsA: Activate an event when it’s moving
In the method onCreate() get a reference to Imageview and assign it a onClickListener: imgPiguim = (ImageView) findViewById(R.id.imgPinguim); imgPiguim.setOnClickListener(new View.OnClickListener()…
-
3
votes3
answers5735
viewsA: What is the basis for.Oncreate(Bundle) and what is Bundle?
The method onCreate() is one of the methods of the so-called Life cycle of the Activity. Activity is a class that should not be instantiated directly, if only created by the system Android, in…
-
3
votes1
answer51
views -
2
votes1
answer732
viewsA: Selecting a Radiobutton from a Radiogroup, according to one condition
Use the method check in() class Radiogroup: if (user.hasCar()){ mSwitchButtonGroup.check(R.id.goes_by_car); }else { mSwitchButtonGroup.check(R.id.doesnt_go_by_car) }…
-
4
votes1
answer471
viewsA: Compare geopoints with user geolocation
To calculate the distance, in meters, between two coordinates can use the class Sphericalutil of Google Maps Android API Utility Library. Add the following application Gradle dependency:…
-
2
votes1
answer438
viewsA: Fast and continuous change of the background color of a Panel
The application hangs because it is running a loop infinite. You also don’t see the background changing color for the same reason, as Uithread is blocked from running this code, the windows…
-
5
votes1
answer1080
viewsA: Exact division (whole)
To get the rest of the division of two numbers use the module operator %. See the following code: while(valor1 % valor2 != 0) The condition at the top means that while the rest of the valor1 for…
-
1
votes1
answer205
viewsA: Android error - Must specify preferenceTheme in Theme
In the archive res/values/styles.xml add <item name="preferenceTheme">@style/PreferenceThemeOverlay</item> If you haven’t changed anything in the file generated by Android Studio will…