Posts by viana • 27,141 points
761 posts
-
2
votes1
answer145
viewsQ: 2 clicks to open the Popover again
I’m creating a popopver where I inserted a close button. As shown below in the image: HTML: <div class="dropdown" style="float: right;"> <button type="button" class="btn btn-default btn-xs…
-
0
votes2
answers1048
viewsA: Bringing a sum in Sqlite Android
Use the method getColumnIndex to redeem the first value of your query. See below how it should be done: Cursor stmt = db.rawQuery("SELECT SUM(SUBSTR(VALOR,3,20)) FROM " + TABLE_NAME, null); if…
-
0
votes1
answer768
viewsA: String JSON - Two decimal places
You can first convert to double and to use the format. See: double value = Double.parseDouble(jsonWinthor[2]); String strValue = String.format("%.2f", value ); Behold in those answers other ways to…
-
2
votes1
answer450
viewsA: How do I get the Calendar date on Android?
It would be interesting to first format the received date. For this you can use the class SimpleDateFormat using the method getTime of your calendar. See: SimpleDateFormat sdf = new…
-
2
votes2
answers1220
viewsA: "Expression expected" error
It seems to me you’re putting your method updateLabel() within the onCreate when you should actually be out. See an example: @Override protected void onCreate(Bundle savedInstanceState) {…
-
1
votes1
answer1118
viewsA: Voice recognition on Android
Basically you need to create an intention using the RecognizerIntent. See the explanation in the code: // cria um intent usando para abrir a tela de captura de voz Intent intent = new…
-
1
votes4
answers2194
viewsA: Subtract one hour from Current time
One option is to use the method sub to subtract an interval using the DateInterval in which PT1H represents 1 hour. See: $date = new DateTime('00:12:00'); $date->sub(new DateInterval('PT1H'));…
-
3
votes2
answers7146
viewsA: round edge on Edittext Android
At first, there are 3 options to do this: Create a background customized and set in XML EditText; Create a background customized and programmatically set in EditText; Create a background…
-
0
votes2
answers398
viewsA: Log in with user or email in the same field
So that you can log in with username and email at the same time, you should add in your query an OR. Example SELECT username, password FROM users WHERE (username = "usernameRecebido" OR email =…
-
2
votes1
answer165
views -
1
votes2
answers197
viewsA: Error in onclick
You can simplify it this way: function mesmoEmail(el){ var marcado = el.value; console.log(marcado); } <input type="checkbox" name="MesmoEmail" value="S" id="mesmoEmail"…
javascriptanswered viana 27,141 -
1
votes1
answer203
viewsA: Know the size of an image on Android
Considering, at first, that you’re using a ImageView, an option is to create a variable of type ViewTreeObserver and use the method addOnPreDrawListener to be "watching and listening" to view…
-
3
votes1
answer95
viewsA: How to block my app if you don’t have internet
A simple way is to let the user enter the application and inside you check if there is a connection. If there is no internet connection, use the method finish() to finish the application. See:…
-
2
votes1
answer846
viewsA: Subtract input date with current date
See below for an easy way to calculate difference using the Math with the methods abs() and ceil(). Math.abs(x) : returns the absolute value of x, in which the difference in dates is calculated…
-
14
votes1
answer994
viewsQ: What are Raw Types?
Reading and studying a little about Kotlin, I found the following statement: The Raw Types are a big problem, but for reasons of compatibilities they had to be maintained in Java, but Kotlin for…
-
1
votes2
answers32
viewsA: Register - comparison of existing or non-existent values
Use the method strcasecmp to compare. See: $var1 = "Teste"; $var2 = "teste"; if (strcasecmp($var1, $var2) == 0) { echo '$var1 é igual a $var2 numa comparação sem diferenciar maiúsculas e…
-
2
votes2
answers374
viewsA: Why am I getting the error : android.content.res.Resources$Notfoundexception: Resource ID #0x0
Instead of leaving the second parameter as 0 in his ArrayAdapter, pass the android.R.layout.simple_spinner_item as layout item. See how it should look: ArrayAdapter<String> adapterLetras = new…
-
0
votes3
answers2367
viewsA: Transparent menu with color change when moving the mouse
Look at this, creating a ul.active with different color background. Thus, you can use the method addClass and removeClass when to use the scroll. Take a look if this way resolves for you:…
-
1
votes1
answer631
viewsA: Save value of a variable in Laravel
With PHP, an option would be to save the id us cookies using the function setcookie. Example: setcookie("empresa_id", '15'); To redeem the value of cookie who is saved, just use $_COOKIE. Behold:…
-
3
votes1
answer372
viewsA: Error using "greater than" in select command with case
According to the documentation, the syntax of your query is incorrect. It should be something like this: CASE case_value WHEN when_value THEN statement_list [WHEN when_value THEN statement_list] ...…
-
1
votes2
answers737
viewsA: Doubt about displaying inverted array
In the second loop of repetition has a variable with name tamanho in which it receives the size of vetor1. In this way: int tamanho = vetor1.length; That means right now tamanho = 5 for vetor1 has 5…
-
4
votes6
answers8998
viewsA: Sum of multiples of 3 or 5
Just adding, everything depends on interpretation, where can go wrong. In the question speaks ...multiples of 3 and 5 below 1000. That is to say i % 3 && i % 5 I would do in this wayideone:…
-
2
votes1
answer444
viewsA: What is the best way to download files and save them to different folders within the android Assets?
Cannot save a file inside the folder assets after already packaged and generated the APK, as it is read only. See here in the documentation of Android existing storage options. However, if you want…
-
3
votes4
answers123
viewsA: How to check if one String completes another?
One option is to use the method String.prototype.search(). If the return is -1 does not exist, otherwise it is because it exists. See: var str1 = "O menino joao foi ao mercado"; var str2 = "joao…
-
0
votes2
answers76
viewsA: PHP consultation repeating the medicine
Use the DISTINCT not to return repeated items. See: SELECT DISTINCT a.crm, a.data_receita, a.data_dispensacao ...…
-
1
votes1
answer290
views -
5
votes1
answer334
viewsA: Transform variable into array
In the first case, an option is to use the split() to separate by space. See: var nome = "João Miguel Pedro" var nome1 = nome.split(" "); console.log(nome1); Or you can make one regex to make a…
-
4
votes3
answers185
viewsA: Animation in images
Only animate().rotation(angle).start() within the method setOnClickListener of your button would already solve the problem. So, just set a value for the variable angle, which would refer to the…
-
5
votes1
answer1098
viewsA: Login with Android PHP and Mysql
Based on the response that is returning from your PHP, within the method onPostExecute() just create a condition. For example: if(result.equals("login success !!!!! Welcome user")){ // aqui o…
-
0
votes1
answer255
viewsA: Position Textview Android Studio 2.2.2
Nothing that a LinearLayout with vertical orientation cannot solve. See: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"…
-
1
votes1
answer523
viewsA: Text does not appear in the land/Activity.main app in Android Studio 2.2.2
What it looks like is that you have two files of strings. Because in one language is in English, the other is in Portuguese. Check in your Resources and insert the text exactly into the appropriate…
-
3
votes1
answer44
viewsQ: Preparation of text for pagination description
I have a text showing how many items are being viewed per page based on the total number of items in the database. See an image: I created an "algorithm" (which I don’t think is cool) to define in a…
-
2
votes2
answers471
viewsA: Place text under the image
There are several ways to solve the problem. As for example insert a LinearLayout with vertical orientation. See: <?xml version="1.0" encoding="utf-8"?>…
-
5
votes1
answer115
viewsQ: What is Lazy instantiation?
I saw here on wakim’s response that code snippet: data class Person(val firstName: String, val lastName: String) { val fullName: String by lazy { "$firstName $lastName" } } What is this so-called…
-
6
votes1
answer1794
viewsQ: What is the purpose of "data class"?
In Kotlin it is possible to create a class as follows: data class Dragon(private val name: String, val glass: Int) What is the main objective of the data class in Kotlin? When should we use?…
-
3
votes1
answer169
viewsA: How to keep a Textview text after the App closes
A simple form of data persistence is to use the SharedPreference as shown in the documentation on How to save key value sets. Below is an example of how to save, considering you have any variable…
-
8
votes4
answers3000
viewsQ: Equivalent to the conditional or ternary operator in Kotlin
Below I am logging on the monitor of Android Studio in JAVA a short phrase using conditional or ternary operator (?)en. Look at: Log.wtf(GOT, (valirianSteel == 0 && glassOfDragon==0) ?…
-
8
votes2
answers335
viewsQ: How to customize the getter in Kotlin?
When we create a variable of type val, in the case of Java, only the getter relative to it. Different when a type variable is created var, in which the getter and setter. See below for an example:…
-
6
votes2
answers296
viewsQ: What is the Anko?
Already converting my Android projects to Kotlin, in some researches I’ve been doing, several times quoted a Anko Kotlin. What is this Anko? What is this about? What is your goal?
-
4
votes1
answer781
viewsQ: What is the purpose of the Ternal lateinit?
I converted to the Kotlin a simple Fragment with any button. In the alternation, it basically looked like this: Java private Button btn; Kotlin internal lateinit var btn: Button What is the purpose…
-
1
votes0
answers34
viewsQ: Insert edit points blocking user interaction
Using the Google Maps Javascript API, with this code below I am creating a PoLyline, that would be a line on the map passing a array of coordinates in the path. Look at: Polyline maplines = new…
-
1
votes1
answer268
viewsA: Pass value from Dialogfragment to Fragment
Implement in your Fragment the DatePickerDialog.OnDateSetListener. See an example below: public class ArticleFragment extends Fragment implements DatePickerDialog.OnDateSetListener { @Override…
-
5
votes3
answers1764
viewsQ: How to create a static method using Kotlin?
In JAVA when we want to create a static method, we use static. Look at: public static String getDragonGlass(){ return String.valueOf("All the dragon glasses."); } And in the Kotlin, how best to…
-
3
votes2
answers68
viewsA: App that every day of the week shows an Activity
If it is weekly, it can be something simple using the Calendar.DAY_OF_WEEK. Behold: // resgata a data atual Calendar calendar = Calendar.getInstance(); int day = calendar.get(Calendar.DAY_OF_WEEK);…
-
3
votes1
answer204
viewsA: What is it, Beacon?
Similar to the NFC(Near Field Communication), the Beacons interact with smartphones when positioned at a given distance radius using the Bluetooth. It’s basically a tech-friendly name "indoor…
-
0
votes1
answer887
viewsQ: Check and uncheck all checkboxes
First, there’s this question about Check/Uncheck all checkboxes except disabled checkboxes, however I do not want you to uncheck what is already marked when you click again. I want you to uncheck…
-
2
votes2
answers100
viewsA: Scroolview passing the Toolbar
Insert a id in his AppBarLayout. Behold: <android.support.design.widget.AppBarLayout android:id="@+id/appbar" android:layout_width="match_parent" android:layout_height="wrap_content"…
-
2
votes2
answers339
viewsA: Swipe Refresh in Textview
In your class, use the method setOnRefreshListener by changing the content of your TextView. That’s all: SwipeRefreshLayout swipeLayout = (SwipeRefreshLayout) findViewById(R.id.swipe);…
-
4
votes1
answer314
viewsA: Android Animation hide and reveal text
You can use the abstract class Animation to carry out the animation, and the class AlphaAnimation to smooth the transition. Then just use the method setRepeatMode() as REVERSE and the method…
-
2
votes2
answers166
viewsQ: Loading on top of the map
I have the following code drawn 2 polygons on the map. See: function initialize() { // Define the LatLng coordinates for the polygon's path. var bounds = new google.maps.LatLngBounds(); var i; var…