Posts by Márcio Oliveira • 2,237 points
129 posts
-
1
votes1
answer517
viewsA: Androidmanifest.xml Error - A pseudo-attribute name is expected.
That stretch: android:hardwareAccelerated="true" is loose in the code. It should be inside the TAG <application>, like the others. The manifest should also start with this TAG: <?xml…
-
1
votes1
answer225
viewsA: How do I limit the number of lines in a listview
Just limit the SQL query to the database. In your case it would look like this: SELECT coluna FROM tabela ORDER BY algo LIMIT 10 If you are using the query() method of the Sqlitedatabase class, you…
-
1
votes1
answer266
viewsA: How do I stop Keyboard from messing with my layout?
Declare that line in your Activity within Androidmanifest: <activity android:name="MyActivity" ... android:windowSoftInputMode="adjustPan" ... </activity> As explained by the Android…
-
0
votes2
answers161
viewsA: Null Object Reference when opening a Dialog Fragment
You didn’t initialize the object GPSFragmentActivity gpsFragmentActivity nowhere in the Aboutscreen class code.
-
0
votes1
answer241
viewsA: update listview automatically when a new data is inserted in the database
You can create a ContentProvider in your app, to access/manipulate database data (in place of direct queries to the database) and implement a CursorLoader in your Activity (which will get the data…
androidanswered Márcio Oliveira 2,237 -
2
votes1
answer50
viewsA: Why does my database ( Sugar ) return null when I search by id?
I’ve never heard of this Sugar, but from the documentation of it, I believe you should look for the object to delete in this way (because you’re using the notation @Table in the creation of the…
-
1
votes1
answer223
viewsA: How to get inverted Recycleview position?
You can set the position to delete in the database this way: int positionToDelete = adapterSize - adapterPosition; // supondo que o índice do primeiro registro é 1, conforme documentação do Sugar.…
androidanswered Márcio Oliveira 2,237 -
-1
votes1
answer208
viewsA: How to Save an Image to the Database
It is possible to save images to the database by converting them to an array of bytes (byte[]) and store them as a BLOB in the bank, but from experience it is not performative, because this constant…
-
1
votes1
answer260
viewsA: Error while trying to add an image as a button background
You seem to be loading a very large image on the button (by the error message). Why not swap the button for an imageView and use Picasso to upload the image anyway? It does all the decoding of the…
-
0
votes2
answers121
viewsA: Pick up news from a website automatically
Basically you’ll have to study the site’s API and see how it returns the data (usually a JSON string) and if you need an application key to access it. Then just implement routines to connect to the…
androidanswered Márcio Oliveira 2,237 -
1
votes1
answer537
viewsA: Recycleradapter with different layouts
It takes more than getItemViewType to solve the problem. First you have to define what you want. In your case, I found the approach of changing the layout of Recyclerview items according to the…
-
1
votes2
answers143
viewsA: It is possible to open Activity inside framelayout
You can use a layout with Viewpager at the top (to display the contents and swipe between them horizontally) and a Tablayout at the footer to mount the bar as from the photo and also toggle the…
-
1
votes2
answers415
viewsA: Access Sqlite database in another Activity
You can do it this way: // Criar os objetos do banco na sua Activity CriaBanco helper = new CriaBanco(this); SQLiteDatabase db = helper.getWritableDatabase(); ... // Manipular o banco com query,…
-
2
votes1
answer109
viewsA: Why does the program close when I click the button?
Its Changefish() function, because it is associated with onClick in XML, must have a view as parameter, so it should look like this: public void ChangeFish(View v) NOTE: Your "for" in this function…
-
0
votes1
answer68
viewsA: Problems with the instantiation of the chronometer
You don’t seem to have initialized this "clock" object anywhere in the code, so when you try to call a method in something null, it gives the error that you posted.
-
0
votes1
answer184
viewsA: How to pass the received data from an activity and put it into a recyclerview
Your Recyclerview expects an Arraylist and you are passing only a single item from the first Activity to the second. If you want to show only this item, you have to modify the Arraylist startup of…
-
2
votes1
answer385
viewsA: Error while performing an SQLITE table creation
I believe it must be because you included a "!" in the column name on that row: String[] colunas = new String[]{"_id","nome","email!","np","tipoFunc"}; Since you are searching for data from all…
-
5
votes2
answers1548
viewsA: How does Asynctask actually work?
The official documentation is well explained in: https://developer.android.com/reference/android/os/AsyncTask.html But basically, Asynctask is made to run background tasks to not burden the…
-
2
votes1
answer417
viewsA: Calling a method of the class of the Fragment itself
1) Remove this line from XML: android:onClick="salvarUsuario" 2) Inside Oncreateview() of Fragment put this code before Return: @Override public View onCreateView(LayoutInflater inflater, ViewGroup…
-
0
votes2
answers245
viewsA: Error using a Static final String to build an SQL query
The error is in your SQL string. You are not passing any parameters in the SELECT clause. It has to be: SELECT <coluna1, coluna2, etc> FROM <tabela> or SELECT * FROM <tabela> to…
-
1
votes1
answer70
viewsA: I’m not getting the inclusion of the bank
You are trying to insert into a column that has a typo ("terafa") in the INSERT query. The application should crash on this line, but as you wrapped the code with a Try-catch block, it simply closes…
-
0
votes1
answer56
viewsA: Spinner returning Null and Void
The mistake says it all. You are trying to set a setOnItemClickListener in Spinner somewhere in the code, but Spinner does not implement this interface. As the documentation, you have to set the…
-
0
votes1
answer334
viewsA: How popular is Alertdialog in Android Studio?
Due to the error, some of your Textview was not found correctly by the respective findViewById in Java. You have to debug and see which one is (the one that returns null for the variable). Plus its…
-
1
votes2
answers76
viewsA: How do I search for a string in a table on Android?
Modify the line that uses the "search" parameter in this way: String where = "clas like '%" + pesquisa + "%'";
-
1
votes1
answer89
viewsA: Animation for android
You can use an animated gif with this animation already ready and load it into an Imageview like any other image. You can use the Glide library for this. Example: Glide.with(this)…
androidanswered Márcio Oliveira 2,237 -
0
votes2
answers460
viewsA: How to update Listview after deleting item?
Your Adapter is connected to an Arraylist. notifyDataSetChanged() will only take effect if you remove an item from that Arraylist and then call the method. In your case, you are doing this after…
androidanswered Márcio Oliveira 2,237 -
0
votes1
answer291
viewsA: Asynctask onPreExecute method problem - Android Studio
I believe you are using an unnecessary Asynctask, as all it does is initialize a Listener that has no guarantee that it will return any value before the Asynctask completes. Why don’t you try a…
-
3
votes1
answer41
viewsA: Why some actions give error if I do not specify the View as parameter in Android?
A view as a parameter is only required in methods you define in the "android:onclick" attribute of the views in XML, because internally Android arrow an onClickListener to them through the method…
-
0
votes2
answers301
viewsA: Null Object Reference JAVA
The error is because the findViewById() of this line: TextView toolbarTitle = (TextView) getActivity().findViewById(R.id.toolbar_title); is returning null, IE, did not find a view with that id and…
-
2
votes1
answer499
viewsA: Programming with sounds for android
The Mediaplayer class plays MIDI smoothly as the MIDI format is natively supported by Android according to official documentation: https://developer.android.com/guide/topics/media/media-formats.html…
-
2
votes1
answer327
viewsA: How to open a dialog to search a file on Android? A Filedialog
You can use this code that will return the URI of the image selected by Picker. Then you can use this Uri to upload the image or send it somewhere else. Intent intent = new Intent();…
-
2
votes1
answer53
viewsA: How can I separate items from a sharedPreferences into an Array?
Trade your code for this one: SharedPreferences sharedPreferences = getSharedPreferences("arquivoPreferencia", MODE_PRIVATE); List<String> frasesFavoritoArray = new Arraylist<>();…
-
0
votes1
answer27
viewsA: Change Layout with your finger
You have to use the component called Viewpager that allows you to slide sideways between several Fragments. For this you will also need to implement an Adapter for the same that will load the…
-
0
votes1
answer88
viewsA: Toast She’s in trouble
You are testing the user/password within a loop that scans the entire list of users returned from the server, so if-Lse is running several times until the end of the loop. At some point in the loop,…
-
2
votes2
answers508
viewsA: How to check if a String is null and add in an array?
If your Extras are only having such texts, would do so, so the code does not depend on the name of each extra or the amount of them: Bundle extras = getIntent().getExtras(); if (extras != null) {…
-
4
votes1
answer78
viewsA: Error running a phone call
Your code that builds the Intent to start the dialer is wrong. It should be so: Intent it= new Intent(Intent.ACTION_DIAL); it.setData(Uri.parse("tel:34621026")); if…
androidanswered Márcio Oliveira 2,237 -
2
votes1
answer636
viewsA: How does the use of DPI Layouts and Redeemers work?
1) Android knows the device resolution and automatically chooses the folder (if any created) that has the closest DPI resolution of the detected resolution. If there is no folder with the resolution…
-
1
votes1
answer58
viewsA: Removing items from a list
Your code has several errors. When you use "views" to save the size of the Array and at the same time delete elements of the Array within the loop, one time this will give error because while the…
-
0
votes1
answer107
viewsA: Is there a function that changes the background of an Activity in android studio?
You can change the background of the layout that occupies the entire Activity with the setBackgroundColor method(). For example: Your XML: <FrameLayout android:id="@+id/root_layout"…
-
3
votes2
answers840
viewsA: Create elements at runtime on Android
Yes, it is possible. You can use the addView() method in any Viewgroup as Linearlayout, Relativelayout, etc. Follow an example: package com.example.androidview; import android.os.Bundle; import…
androidanswered Márcio Oliveira 2,237 -
1
votes1
answer462
viewsA: How to store more than one value using Sharedpreferences?
The values saved in Sharedpreferences work as a "Value Key" pair. To store multiple values, you have to use separate keys. In your case, you are using the same "phrases" key for the entire list. You…
-
1
votes2
answers1100
viewsA: Intent stopping the App in Android Studio
Your Activity Books is not inflating the layout book_data.xml (which contains custom_view_parseDedited), so when you try to initialize the mAnaliseButton variable with findViewById(), it returns…
-
0
votes1
answer126
viewsA: android - Unit testing and UI testing
It is always worth testing. Each Framework has its scope of use. Junit4 serves, for example, for unit tests that do not rely on Android components to run (e.g., class testing, some method of…
-
1
votes2
answers5047
viewsA: How to properly organize DP and DPI for each screen type on Android?
But the concept of PD is just made for this, keep the same size of the views between different screen resolutions. For example, if you have devices with the same screen ratio (for example, 16:9) but…
-
0
votes1
answer72
viewsA: I need to create an Intent inside another Intent
Seven a different Action or Extra on each of the intents and then on Mainactivity recover the same and do the necessary action based on what was captured.
-
0
votes1
answer158
viewsA: Activity Lifecycle + system.currentTimeMillis()
Take a look here: https://www.tutorialspoint.com/java/lang/system_currenttimemillis.htm Explain in more detail what I quoted in my last comment. But basically the logic is you use…
-
0
votes1
answer54
viewsA: Listview does not respond with background effects when clicking on item
Try to exchange the value of the "android:background" attribute of your Constraintlayout for this: android:background="?attr/selectableItemBackground" In Recyclerviews enables the click effect, I…
-
0
votes2
answers301
viewsA: Select with two columns returning empty
The relationship between the tables appears to be 1:1 (or will your application allow 2 users to have the same login user?). If it is 1:1, why create 2 tables? I am not seeing any gain in this…
-
0
votes1
answer92
viewsA: Return onPostExecute() String
You have to implement the interface created in Asynctask in the Mainactivity statement. For example: public class MainActivity extends Activity implements PutMethodDemo.OnPostCompletedListener { ...…
-
2
votes1
answer352
viewsA: How to catch the state of toggleButton Android?
the method is isChecked(). It is inherited from the Compoundbutton class. Ex: if(myToggleButton.isChecked()) // Faça algo se estiver checado else // Faça algo se não estiver checado…