Posts by Leonardo Dias • 4,336 points
198 posts
-
1
votes1
answer163
viewsA: Error creating Google Maps Activity
Cristian, Take a look at your Androidmanifest.xml You’ll notice there at the end that’s like this: <meta-data android:name="com.google.android.geo.API_KEY" android:value="@string/google_maps_key"…
-
6
votes2
answers3867
viewsA: Add Item to Spinner
You can declare a String array and include in it Example: String spinnerArray[] = {"Item1", "Item2"}; And then include in standard Adapter: ArrayAdapter<String> spinnerAdapter = new…
-
3
votes1
answer82
viewsA: How to play a layout component up?
Rogers, You need to understand the difference Invisible and Gone. If you use the android:visibility="invisible" the layout will remain there, however invisible, so his space continues. Now if you…
-
1
votes1
answer305
viewsA: Element fixed on top of the keyboard
Have you tried adding adjustPan to your manifest? Example: <activity android:name=".SuaActivity" android:windowSoftInputMode="adjustPan|adjustResize"> </activity> This will make that…
-
1
votes2
answers69
viewsA: How do you make it when the user touches the menu symbol and the message appears in Toast?
If you are inflating the menu layout, you can add the item there in the same xml, need not be programmatically. example: <menu xmlns:android="http://schemas.android.com/apk/res/android"…
androidanswered Leonardo Dias 4,336 -
1
votes1
answer345
viewsA: Click the button on Toolbar
Do it this way to get the clicks from Toolbar: @Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); if (id == R.id.btnSalvar) { String nomeDesc =…
androidanswered Leonardo Dias 4,336 -
3
votes1
answer665
viewsA: Error grabbing the selected item in a Spinner and showing in a Toast
setOnItemClickListener cannot be used in Spinner Use setOnItemSelectedListener in place Example: cidade.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void…
-
3
votes2
answers831
viewsA: Checkbox condition isChecked
You need to already set it as checked, even before the Changelistener Example: cbx22.setSelected(true); By the time he gets on the Changelistener he’ll be checked out…
-
2
votes1
answer83
viewsA: Two Intents starting the same Activity
I would pass a Extra Beta to another Activity: Instead of: startActivity(new Intent(getApplicationContext(), MainActivity.class)); Do: Intent intent = new Intent(getApplicationContext(),…
-
0
votes1
answer230
viewsA: Facebook Login with REST API
After the login response made via Facebook. You can check if the session is really open, and grab the user token Example: Session session = Session.getActiveSession(); if (session.isOpened()) {…
-
0
votes2
answers61
viewsA: Edittext with ellipsis
You need to do it this way in XML <EditText ... android:maxLines="1" /> And then you need to put in Java String text = edit_text.getText().toString(); if(text.length() > 8){…
-
1
votes2
answers4044
viewsA: Share button
You need to use the function Shareactionproviders Example: <menu xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@+id/menu_item_share"…
-
1
votes2
answers252
viewsA: How to control the lighting (brightness) of Android via code for all activities?
First you need permission <uses-permission android:name="android.permission.WRITE_SETTINGS"></uses-permission> Arrow the variables private int brightness; private ContentResolver…
androidanswered Leonardo Dias 4,336 -
0
votes3
answers703
viewsA: Change native font size
It would be better if you put your code here to see possible errors in your code. But do the following test, in your main style put the item Textsize <style name="AppTheme"…
androidanswered Leonardo Dias 4,336 -
1
votes1
answer182
viewsA: Close ad by clicking close button
Man, by the X of the ad I believe you can’t control What you can do is set an ID in the layout and manually create a button to close the ad Example: <LinearLayout…
-
4
votes2
answers499
viewsA: Error android.database.sqlite.Sqliteexception: no such table: fs_promocoes
This is because you added a new table without changing the version of the database. You can uninstall the application and run again to resolve or just change the database version. But as your…
-
0
votes2
answers41
viewsA: onKeyDown when Spinner is open
And if you use the onBackPressed? @Override public void onBackPressed() { //aqui você controla o voltar fisico do aparelho }
-
5
votes1
answer589
viewsA: How to translate java code?
You have the file res/values/strings.xml, correct? Then you must create a new directory values referring to the language you want to use in the APP, for example: res/values-fr/strings.xml…
-
2
votes2
answers1726
viewsA: How to create a Library-Android using Android Studio?
You must create a normal project The difference is in the file app/build.Radle, that you need to indicate to the Gradle build that this project is a lib, then add the following lines at the…
-
3
votes1
answer41
viewsA: How do I disable a function when and old android API
You should check which API the application user uses Example: int currentapiVersion = android.os.Build.VERSION.SDK_INT; if (currentapiVersion >= android.os.Build.VERSION_CODES.LOLLIPOP){ // faz…
-
3
votes2
answers111
viewsA: Error in delete button
The error is in the parameter that the method delete are receiving public void delete(long id){ SQLiteDatabase d = getWritableDatabase(); if (id > -1) { d.delete("resultado", "id = " + id, null);…
androidanswered Leonardo Dias 4,336 -
1
votes1
answer36
viewsA: Click on FAB but do not switch to new Intent
You are declaring in XML as Floatingactionbutton? Your Java should look like this: FloatingActionButton cadastrar = (FloatingActionButton) findViewById(R.id.fab); cadastrar.setOnClickListener(new…
androidanswered Leonardo Dias 4,336 -
1
votes1
answer2188
viewsA: Instagram intent of the error in webview?
You can solve the problem using the following code, works correctly to open links on Instagram right from your application. Uri uri = Uri.parse("https://www.instagram.com/hotelcolonialdosnobres/");…
-
0
votes2
answers102
viewsA: Delete onClick error
It seems that you are putting onClick in the XML button, correct? Try to remove this onClick la from XML and do so: apagar = (Button) findViewById(R.id.btndeletar); apagar.setOnClickListener(new…
androidanswered Leonardo Dias 4,336 -
2
votes1
answer421
viewsA: Pick selected image and send to another Activity
You can pass her position. Example: gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View v, int position, long id) {…
-
1
votes1
answer187
viewsA: Positioning with imageView
You must use the Gridview, it mounts like a table with each image in a column. Example of XML: <GridView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/gridview"…
-
0
votes2
answers879
viewsA: Create quit button using onClick
It is easier and better in the usability of the application that you assign an ID to the button and use the Onclicklistener to identify the click, if not you will need to create a method for each…
-
0
votes1
answer102
viewsA: Listview only appears when I click to close the keyboard
Try to close the keypad via code when search view finishes getWindow().setSoftInputMode( WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN );
-
8
votes1
answer3448
viewsA: Mysql Workbench - error unserializing grt data
According to members who have been through the same problem in Stack Overflow English, just restart the Workbench that solves.…
-
6
votes3
answers318
viewsA: Change the format of a date(time) in a String
You need to use the Simpledateformat, thus: public String getHourFormat(String hour){ SimpleDateFormat dateFormatter = new SimpleDateFormat("HH:mm:ss"); Date date; String displayValue = null; try {…
-
11
votes2
answers3271
viewsA: What is the difference between Listview and Recyclerview?
Recyclerview is a new (but not so much) view that has come to replace Listview and Gridview. According to his documentation, this is a more advanced and efficient widget, when compared to its…
-
3
votes1
answer370
viewsA: How to use Recycleview on fragment ?
When you are working on Fragment, you should use getActivity(); in place of this example: RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getActivity(),…
-
1
votes2
answers8134
viewsA: What is the right approach to get the click/position in Recyclerview?
I usually set a TAG to get the correct position. For example: @Override public void onBindViewHolder(final AdapterViewHolder holder, final int position) { holder.imagem.setTag(position);…
-
3
votes1
answer220
viewsA: Recyclerview makes imageview disappear
You better put the code next to the question, to help with the solution. But this "problem" is already known in Recyclerview. You have an Adapter that creates your list, right? Probably at the time…
-
1
votes2
answers278
viewsA: Sending data between View and Edit Activity
Raul, show your code, it’s better so we can help. Here is an example of how to pass data between Activitys: Intent intent = new Intent(LoginActivity.this, UserSignupActivity1.class);…
-
0
votes2
answers1014
viewsA: How to solve the cannot find Symbol variable problem?
You need to declare this variable with some value, for example: private static final int RESULT_LOAD_IMAGE = 1;
-
6
votes1
answer963
viewsA: How to change the color of the bottom bar, where the buttons "Back", "Home" and "Active App" are located?
That part is called navigationBarColor and to change it, do the following: Add the line to your style <item name="android:navigationBarColor">@color/sua_cor</item> Or you can change via…
-
1
votes1
answer291
viewsA: How do I close a dialog when the condition is true?
You must use the startActivityForResult example: view.findViewById(R.id.btn_claro).setOnClickListener(new View.OnClickListener() { public void onClick(View arg0) { onStop();…
-
0
votes2
answers761
viewsA: Error - Binary XML file line #30: Binary XML file line #30: Error inflating class Fragment
1st option: Check the layout_frag_1.xml, if the parent tag has Fragment id, example: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical"…
-
2
votes1
answer692
viewsA: Clear old notifications the moment you enter the app
You can put this on the onCreate of your Thread UI: NotificationManager nMgr = (NotificationManager) getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE); nMgr.cancelAll(); The…
-
3
votes1
answer512
viewsA: Parametric passage from one fragment to another
You should use Bundle as well, see an example: To send to another Fragment Seu_Fragment fragment = new Seu_Fragment(); Bundle bundle = new Bundle(); FragmentTransaction fragmentTransaction =…
-
1
votes2
answers286
viewsA: How do I publish apps for tablets in the Play Store?
Give a check, if you use any specific permission only for smartphones, such as the link: <uses-permission android:name="android.permission.CALL_PHONE"></uses-permission> For it to work…
-
0
votes1
answer95
viewsA: Android composite control Textview + Switch - click method
You need to add one Listener. It is not necessary to put the onClick in XML. example: CPreferenceSwitch mySwitch = (CPreferenceSwitch) findViewById(R.id.id_do_switch);…
-
2
votes1
answer1397
viewsA: Open camera/file by Webview
Permissions are missing in your code. On Androidmanifest.xml, for example, you should have: <uses-permission android:name="android.permission.CAMERA" /> Besides the uses-Feature:…
-
0
votes2
answers54
viewsA: How to test an event on the keyboard (Editorinfo.IME_ACTION_DONE)
You need the Oneditoractionlistener Example: EditText et = (EditText) findViewById(R.id.search_field); et.setOnEditorActionListener(new EditText.OnEditorActionListener() { @Override public boolean…
-
0
votes2
answers910
viewsA: Redirect users to Google Maps app using Waypoints
You must do via Intent example: Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse("https://maps.google.ch/maps?saddr=[address1]&daddr=[address2] to:[address3] to:…
-
0
votes2
answers724
viewsA: Pass a string from an Activity to a fragment maps
You must pass via Bundle in fragmentTransaction example: MapsFragment fragment = new MapsFragment(); Bundle bundle = new Bundle(); FragmentTransaction transaction =…
-
0
votes2
answers608
viewsA: How to change the color of the floating button and insert a text into it
You need to add the line backgroundTint, example: <android.support.design.widget.FloatingActionButton xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="wrap_content"…
-
1
votes1
answer95
viewsA: Error implementing Facebook login button
When declaring your Facebook button, have some small errors: This is your: <com.facebook.widget.LoginButton xmlns:fb="http://schemas.android.com/apk/res-auto"…
-
2
votes1
answer273
viewsA: Separate Item clickable in android Layout
Give a ID pro to your Linearlayout and use the Java click on it. Example: XML <LinearLayout android:id="@+id/acao1" android:layout_width="wrap_content" android:layout_weight="50"…