-1
I need to create a screen that calls another, but I want to do it using only methods, and in the code I did it is not calling the other.
On the first screen I have a list and a button include. When you click the include button, another screen has to appear to enter the name, then I click the ok button include and it goes back to the first screen with the lists showing the new contact adds.
package com.example.pamelaelias.contatos;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;
import java.util.ArrayList;
import java.util.List;
public class MainActivity extends Activity {
ListView lista;
List lista2 = new ArrayList();
Button btnIncluir, btnOkIncluir;
EditText txtNome;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
lista = (ListView) findViewById(R.id.idLista);
lista2.add("Pamela");
lista2.add("Brenda");
lista2.add("Gabriel");
final ArrayAdapter<String> adp = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, lista2);
lista.setAdapter(adp);
}
public void TelaInicial() {
btnIncluir.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
setContentView(R.layout.incluir);
btnOkIncluir = (Button) findViewById(R.id.btnOkIncluir);
txtNome = (EditText) findViewById(R.id.txtNome);
Incluir();
}
});
}
public void Incluir() {
final ArrayAdapter<String> st = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1, lista2);
btnOkIncluir.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
setContentView(R.layout.activity_main);
btnIncluir = (Button) findViewById(R.id.btnIncluir);
lista = (ListView) findViewById(R.id.idLista);
lista2.add(txtNome.getText());
lista.setAdapter(st);
TelaInicial();
}
});
}
}
https://developer.android.com/training/basics/firstapp/starting-activity.html?hl=pt-br
– itscorey
https://developer.android.com/training/basics/intents/result.html?hl=pt-br
– itscorey
Honestly I didn’t understand almost anything you explained, it was even difficult to edit by this. I suggest you edit the question, and explain better what you want to do, it’s very confusing to understand your text.,
– user28595
kkkkkkk ai mds I don’t even know how to explain here, that’s how.. I need to make a screen that has a boot called include and a list, when you click this 'include' button it goes to another screen that has another button called 'ok include' where I will enter a name and when I click this 'ok include' button it goes back to the first screen showing the list with the new name added.
– Pamela Elias