Posts by Leonardo Dias • 4,336 points
198 posts
-
2
votes4
answers496
viewsA: Hide element from Activity
Try to change the: evento_btn.setVisibility(View.INVISIBLE); for evento_btn.setVisibility(View.GONE); View.INVISIBLE will hide the item, but it will keep its space, while View.GONE will remove even…
androidanswered Leonardo Dias 4,336 -
1
votes2
answers186
viewsA: Help to pick up response values on Android with Retrofit
Try to change all the Request for List< Request > Example: Call<List<Pedido>> json = new RetrofitInicializador().getPedidoService().buscaPedido(); json.enqueue(new…
-
1
votes3
answers113
viewsA: problems in passing data to new Activity
The error is in the statement: TextView nomeView = (EditText) findViewById(R.id.emailPrincipal); It is a Textview, but after = you are putting (Edittext). It has nothing to do with the Bundle or the…
-
2
votes1
answer772
viewsA: Toast Message At the heart of Activity on Android
You are starting the Toast 3 times doing this way. For it to work, you must do so: Toast toast = Toast.makeText(MainActivity.this, "Tarefa salva com sucesso!", Toast.LENGTH_LONG);…
-
0
votes1
answer111
viewsA: Retrieve the context of a Class (Model)
private Context context; public PostagemCurtida(Context context) { this.context = context; } And when you call your Model through some class, you pass the context, for example: PostagemCurtida…
-
4
votes1
answer979
viewsA: How to change the color of the icon in drawable layout on android
To change the color of the burger icon you should open the file xml style. And then in this class, add the line responsible for the color: <style name="AppTheme"…
-
1
votes1
answer88
viewsA: Error in database cannot save data in table
The problem is that the system is not finding the table added "Ah! but I put this table yes, it is there!" Okay, so you have two options to solve, First: Go up the version of your local bank, if it…
androidanswered Leonardo Dias 4,336 -
0
votes1
answer25
viewsA: I can’t call Activity for minutes without a button
The code is correct, but probably by setting the time there in the method and also as the end, may be influencing. Try declaring the weather up there in your Activity, for example: public class…
androidanswered Leonardo Dias 4,336 -
0
votes2
answers87
viewsA: Return message if no checkbox is selected
if (cbPapel.isChecked()) Listcheck.add(cbPapel.getText().toString()); if (cbPlastico.isChecked()) Listcheck.add(cbPlastico.getText().toString()); if (cbMetal.isChecked())…
-
1
votes1
answer176
viewsA: Make a method on onCreate run once
You can do an if to see if the song is playing, example: if(player.isPlaying(){ //Ja ta tocando então não faz nada }else{ //inicia o player e toca a música } The method isPlaying() is internal to…
-
0
votes1
answer37
viewsA: Scrowview layout
Victor, To solve this problem, you must go to Androidmanifest.xml and change your Activity record there, for example: <activity android:name=".NomeDaActivity"…
androidanswered Leonardo Dias 4,336 -
4
votes2
answers1710
viewsA: Textview with scratched letter
You must use the code below: TextView tv = (TextView) findViewById(android.R.id.text1); tv.setPaintFlags(tv.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG); That way your text will be crossed out.…
-
0
votes1
answer78
viewsA: Send user to an email app
You can use this code below: Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType("text/plain"); emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new…
-
0
votes1
answer1140
viewsA: Android - Webview button back
You must use the function onKeyDown, example: @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_DOWN) { switch (keyCode) { case…
androidanswered Leonardo Dias 4,336 -
2
votes1
answer250
viewsA: Change Hint Gravity - Edittext
Matheus, For the text, you can use the setSelection, for example: EditText editText = (EditText)findViewById(R.id.edittext_id); editText.setSelection(editText.getText().length()); This way Java will…
-
1
votes1
answer405
viewsA: Swap screen (xml) with login button
You probably are doing Intent wrong, see this simple example: Intent intent = new Intent(this, SegundaActivity.class); startActivity(intent); And you must also remember, to register the…
-
3
votes3
answers915
viewsA: Random without repetition
You must use the command Collections.shuffle(), this way will always be a random number and will not repeat, example: ArrayList<Integer> number = new ArrayList<Integer>(); for (int i =…
-
1
votes1
answer40
viewsA: Universal Player Music with Web Services
Hector, If you access to url, will see how is made the structure of Json that they have created. In order for you to just change the URL to your Webservice, it should look exactly like the one…
androidanswered Leonardo Dias 4,336 -
0
votes1
answer649
viewsA: E/Sqlitelog error: (1) in such column
Aline, You have two ways to solve this problem: 1º You must change the version of your local bank, so that it sees the new columns you added, example: private static final int DATABASE_VERSION = 2;…
-
0
votes2
answers698
viewsA: How to make Linearlayout stay at the bottom of the screen?
You must include the android:layout_alignParentBottom="true", but for the same to work, you have to be the son of a RelativeLayout example: <RelativeLayout…
-
1
votes2
answers920
viewsA: How to know which Fragment is being displayed
At the time of replace, vc should set a TAG to your Fragment, example: fragTrans.replace(android.R.id. content, fragment, "TAG_DO_FRAGMENT"); Then to check which Fragment is being displayed, do it…
-
5
votes2
answers370
viewsA: How to Change Linear Layout Transparency
You can put a transparency in the background color instead of using the colorPrimary See this list where you have the list of transparencies: 100% — FF 95% — F2 90% — E6 85% — D9 80% — CC 75% — BF…
-
0
votes3
answers421
viewsA: Error passing from String to float and from float to String
You must use the parseFloat and toString, example: String to float float f = Float.parseFloat("25"); From float to String String s = Float.toString(25.0f);…
-
1
votes1
answer743
viewsA: Stream audio in android studio
You need to create a Mediaplayer to play it in the app itself. For example: MediaPlayer mp = new MediaPlayer(); try {…
androidanswered Leonardo Dias 4,336 -
2
votes2
answers55
viewsA: Error adding Textview by programming
You cannot define that name Frame with F uppercase, try another name, for example: LinearLayout mFrame = (LinearLayout) findViewById(R.id.container); And then: mFrame.addView(textView);…
-
1
votes1
answer53
viewsA: Navigation Activity
Your Activity, is implementing NavigationView.OnNavigationItemSelectedListener, right? Then you will have a method like this: @Override public boolean onNavigationItemSelected(MenuItem item) { //…
-
1
votes1
answer219
viewsA: Calling screen with Fragment
You need to use Fragmentmanager, example: FragmentManager fragmentManager = getSupportFragmentManager(); fragmentManager.beginTransaction() .replace(R.id.container, NomeDoFragmentAqui, "titulo do…
-
1
votes2
answers828
viewsA: Format Timestamp for string without milliseconds?
You will need to create a method that does the conversion, example: public static String convertDate(String mDate){ SimpleDateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S"); try…
-
1
votes2
answers58
viewsA: How do I make an operation run moments after I have clicked a button?
You need to put it inside a Run, setting the waiting time. For example: final Handler handler = new Handler(); Timer timer = new Timer(); TimerTask doAsynchronousTask = new TimerTask() { @Override…
-
1
votes1
answer1838
viewsA: Error while performing findviewbyid
It seems that you are calling the method via XML: <Button android:id="@+id/altera_perfil" android:layout_weight="match_parent" android:layout_width="wrap_content" android:onClick="AlterarPerfil"…
-
0
votes2
answers986
viewsA: What is the purpose of setTag and getTag methods in View?
I believe that setTag() and getTag() have several functions, but in my projects I use it as follows: Customadapter.class @Override public void onBindViewHolder(CustomViewHolder customViewHolder, int…
-
1
votes2
answers64
viewsA: I don’t understand why the app closes
Peter, This error happens because you are declaring the Layout components even before declaring the layout. These references should be inside onCreate and after setting the layout, for example:…
-
1
votes1
answer33
viewsA: Error while editing through SQLITE
Lucas, When you will put a Fragment in some Activity, you use the following code: FragmentManager fragmentManager = getSupportFragmentManager(); fragmentManager.beginTransaction()…
-
1
votes2
answers301
viewsA: Null Object Reference JAVA
Renan, The problem is here: TextView toolbarTitle = (TextView) getActivity().findViewById(R.id.toolbar_title); When you call the getActivity(), You’re telling him to go look in the Activity layout…
-
-1
votes1
answer969
viewsA: Consume Rest webservice on Android
When you fall in onFailure, you can see what the error is, this way: @Override public void onFailure(Call<List<Imovel>> call, Throwable t) { if (dialog.isShowing()) dialog.dismiss();…
-
1
votes1
answer207
viewsA: Missing server connection via Httpurlconnection
Roger, you can do it this way: Add one more catch, which will be responsible for observing the Timeout, if it runs out of time without response from the server, will fall in it, then just remove the…
-
5
votes1
answer3600
viewsA: How to pass data between Activities
You should use the Intent for this, follow example: 1ª Activity: Intent i = new Intent(Activity.this, NewActivity.class); i.putExtra("key", value); startActivity(i); 2ª Activity: Bundle extras =…
-
1
votes1
answer29
viewsA: Problems with multicones in the android menu
Renan, you need to check the clicked ID, example: @Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); if(id == R.id.favoritar){ if (!restaurante.isFavorito())…
-
3
votes1
answer703
viewsA: Insert Scrollview into all Activity
Fala Lucas, Inside your Scrollview, you can only have one Layout, for example: <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"…
-
4
votes2
answers4903
viewsA: Setando mask android phone field
Fala Renan, It’s much simpler than you think, look at this example: id_do_campo.addTextChangedListener(Mask.insert("(##)####-####", id_do_campo)); Okay, the mask is made. ------------ Edit: Follows…
androidanswered Leonardo Dias 4,336 -
1
votes1
answer276
viewsA: Opening external website in android studio within a list item
You want to send it to an external browser the application? Do it this way: case 5: String url = "http://www.google.com"; Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse(url));…
-
0
votes1
answer52
viewsA: Post via Json getstring error
Samara, The error is occurring because you are declaring Strings twice, and also because you are sending it to the server as text, not as a variable. Example: You stated up there: private String…
-
1
votes1
answer279
viewsA: How to place a title in Ragment?
You can create a method in your main Activity, this way: public void setToolbarTitle(String title){ id_da_toolbar.setText(title); } And then, in Fragment where you want to change the title, you do…
-
2
votes1
answer247
viewsQ: Autocompletetextview with accented words
I’m having some difficulty using Autocompletetextview with accented words. For example: I’m running names of banking agencies, typing only ita the Itaú bank is finding, as the image below: However,…
-
1
votes1
answer51
viewsA: How to open a alertDialog without darkening the screen?
You can declare his background as transparent For example: AlertDialog.Builder alert = new AlertDialog.Builder(activity); alert.setCancelable(true); getWindow().setBackgroundDrawable(new…
androidanswered Leonardo Dias 4,336 -
3
votes1
answer2271
viewsA: How to add a button in Action Bar?
You need to add a method called onCreateOptionsMenu, example: @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.main, menu); return true; } Inside the…
androidanswered Leonardo Dias 4,336 -
2
votes1
answer50
viewsA: White at the bottom of the screen with Scrollview
Try setting the Scrollview height to take the whole screen, example: <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent"…
-
0
votes1
answer753
viewsA: You need to use a Theme.Appcompat Theme (or Descendant) with this Activity
Instead of: <activity android:name=".controller.activitys.MainActivity" android:label="@string/app_name" android:launchMode="singleTask" android:theme="@style/AppTheme.NoActionBar" You must put:…
-
1
votes2
answers124
viewsA: Know if user has Waze installed
You must direct your URI to Waze and if you do not have it you will list the appropriate Apps Example: final Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse("waze://?ll=" +…
-
0
votes3
answers99
viewsA: Custom Listview with Picasso
You are declaring the item layout twice. The right is only here: View rowView = inflater.inflate(R.layout.list_picasso, null,true); Up on the line: super(context, R.layout.list_picasso, nome); Trade…