Take data from one Plain text and put it into another in another Activity?

Asked

Viewed 268 times

0

i have a catalog app that the customer required to be implemented a quantity choice function on each item.

For example: I have the product A (in Activitya), the customer wants 25 units. in product B 05 (in Activityb) and in product C 47 (in Activityc).

I want to take all this data and put it in a Plaintext that is on a contact form, discriminating the amount and name of each item. This form is in another Activity, called Activitycontato.

How can I do that?

Thank you!

  • Thanks for pointing out the possible duplicate, but that’s not what I want. i just want to take the data typed in the Plain text (which will be a number from 0 to 999) and play inside that other text that will be in the form Activity.

1 answer

0


I think if you do this will work and will do what you want. (I’m not sure but try)

Activity(Main)

In the (XML) of the first Activity you put some editText (and each with a id different) and a Button (This is the button you will use besides opening the other Activity you will send the values) and in the part of the code you put like this

private EditText produto_um, ...    ;//(Colocas todos os *EditText* que precisares)
private Button btn_AlgumaCoisa;
produto_um=findViewById(R.id.produto_um);
btn_AlgumaCoisa=findViewByid(R.id.btn_algumacoisa);
btn_AlgumaCoisa.setOnclic...(new View...)
{
//Aqui pegas todos os valores que estam nos *EditText*
String valorUm=produto_um.getText.toString();  
//(Fazes isto para cada *EditText* pois tens de pegar todos eles um a um)
//Depois de pegares todos os valores dos *EditText*
//É só tu fazeres uma *Intent* para abrir a outra *Activity*

Intent abrirePassardados=new Intent(MainActivity.this,ActivityContato.class);
abrirePassardados.putExtra("valor",valorUm); 
starActivity(abrirePassardados);   //(Atencao coloca o metodo que diz Intent 
intent senão ele não ira funcionar)
}

Activity (Contato)

in the code

Bundle dados=getInten().getExtra();

String alguma_coisa=dados.getString(valor);

//por fim colocas esta String alguma_coisa

Componente.setText(""+alguma_coisa);

//That’s about it but you have to create an xml with Textview or any other component and I hope I helped. Have a good weekend.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.