Posts by NX1125 • 428 points
14 posts
-
1
votes0
answers22
viewsQ: How to increment tailSet integers in Treeset<Atomicinteger> without addAll()?
I have the following part of a class: private TreeSet<AtomicInteger> offsets; // ... public void addIndex(int index) { SortedSet<AtomicInteger> set = offsets.tailSet(new…
-
1
votes2
answers1170
viewsA: Format Phone number in Textview - android
Whereas the number is in one long, you can use String.format(): long telefone = 55123456789L; // (55) 1234-56789 // (xx) xxxx-xxxxx String s = String.format("(%02d) %04d-%05d", (telefone /…
-
1
votes1
answer420
viewsA: Rounding numbers on Android
You’re probably using the class android.icu.text.NumberFormat which is API 24. Go to imports and switch to java.text.NumberFormat. The memo to the DecimalFormat: java.text.DecimalFormat.…
-
2
votes1
answer471
viewsA: Listview does not load all items
You are passing to the super only two String in objects.get(0). Change to: public Adaptador(Context context, int textViewResourceId, ArrayList<String[]> objects) { super(context,…
-
1
votes2
answers877
viewsA: Textview is not displaying decimal numbers of a long type variable!
Cast a cast of n02 for float: tvResult.setText(String.valueOf(n01 / (float) n02)); With a limited number of decimal places: // altere 2 em "%.2f" para a quantidade de casas decimais…
-
0
votes2
answers3011
viewsA: Write to.txt file
It is very similar to the file system on the desktop. Using the Android Developers, use File: File arquivo = new File(context.getFilesDir(), "arquivo.txt"); FileOutputStream output = new…
-
1
votes1
answer711
viewsA: Update in Sqlite Table via Imagebuttom Android Studio
In the CustomAdapter create an interface that will be called when a Employee is favored or not favored: interface OnFavoriteEmployeeListener { void onFavorite(Employee e, boolean fav); } A field and…
-
1
votes2
answers212
viewsA: When I delete the last Edittext character from the PARA app, what to do?
Instead of setting the text to 0 when empty, use hint for this: editText.setHint("0"); Now when you get the number, you have to check if it is virtual zero (no input) or text: long valor; String…
-
1
votes1
answer697
viewsA: how to popular the object array with Sqlite data
You need to do a survey to get students and get information from Cursor of the research. The SQLiteDatabase has the functions query or rawQuery which searches with table information, columns etc.…
-
1
votes4
answers148
viewsA: Background of Imagebuttons
getDrawable() returns a Drawable while setBackgroundResource(int) has a int as input. Use findViewById(R.id.imgB6).setBackground(v.getBackground());…
-
7
votes3
answers1013
viewsA: Contains in Java, how to search a text in an Arraylist?
If you need a procuca with case insensitive, use Pattern: ArrayList<String> strList = new ArrayList<>(); strList.add("Paula"); // será encontrado strList.add("Paulo"); // será encontrado…
-
2
votes2
answers831
viewsA: Checkbox condition isChecked
The Istener will not be called if the CheckBox has been checked before setting the Switch. You are probably checking inside the layout with android:checked="true". Use android:checked="false" in the…
-
3
votes2
answers364
viewsA: How to create Checkbox via programming
Use ListView. ListView organizes the items vertically and has an adapter that creates a View required for each item in the list. Put Listview where you want it in the layout. For example: <?xml…
-
0
votes4
answers197
viewsA: Calling Gridview event in Activity
You can open the Gridview Activity, delete the items and then return the amount of items to the Textview Activity. In Activity with Gridview (I will name Gridviewactivity) should call the method…