Posts by Diego Simões • 100 points
11 posts
-
0
votes3
answers654
viewsA: How to separate a number into two
double x = 125.69; double decimal = x % 1; double inteiro = x - decimal; System.out.println("Decimal: "+decimal); System.out.println("Inteiro: "+inteiro);
javaanswered Diego Simões 100 -
0
votes1
answer96
viewsQ: How to extract String from a larger string separated by "/"
I have a string and want to extract a substring see in my code: String link = "lojas/RJ/Macaé/Loja Modelo/pedidos_ativos/03-03-2018-8773"; String uf =…
-
0
votes2
answers2211
viewsQ: How to change the title of an Activity?
I have an Activity and I need to change its title programmatically, I found a way but it doesn’t work for me, check it out: protected void onCreate(Bundle savedInstanceState) {…
-
0
votes2
answers275
viewsA: Find patterns within a String
Can be done by creating a List and a pojo class with two Strings Cpf and birth //Variaveis preliminares List<Pessoa> todos = new ArrayList<Pessoa>(); String str =…
-
0
votes1
answer182
viewsA: Insert a code into Mainactivity
You must insert the first 3 lines inside onCreate and the rest outside onCreate as shown in the code: public class MainActivity extends AppCompatActivity { private AdView adView; private Button…
-
0
votes1
answer43
viewsA: Taking an attribute from a Class
You can allow the class to be instantiated without requiring the context by creating another constructor with only the String query as parameter. Now you will not be able to use any internal method…
androidanswered Diego Simões 100 -
2
votes2
answers1711
viewsA: Required field, fill in before saving
You need to generate some feedback in the method validate(), in my case I like to use a string and go adding to it the error messages and right in the first line of onClick I check if the string is…
-
1
votes5
answers23968
viewsA: How to get and format current date and time?
In this example generates two day and hour strings, with the format for day 02-03-2018 and time string 22:21:30 Calendar calendar = Calendar.getInstance();//cria o obj calendar e atribui a hora e…
-
1
votes2
answers531
viewsA: What is the correct way to get the device date?
In practice uses all these classes, in this example generates two day and time strings, with the format for day 02-03-2018 and time string 22:21:30 Calendar calendar = Calendar.getInstance();//cria…
-
1
votes1
answer1848
viewsA: What’s the best way to present only two houses in a java float
Use this code to format your decimals in float or double float x = (float) 12.309989; DecimalFormat df = new DecimalFormat("0.00"); editText.setText(df.format(x));…
-
0
votes2
answers78
viewsA: How to simplify clicks on buttons in Java for Android?
For each Button you can assign the . setOnClickListener directly with your onClick method inside onCreate as in the example: @Override protected void onCreate(Bundle savedInstanceState) {…