From now on Thank you for understanding everyone, as I am not very experienced. I am having an error loading client data from a list. I want, when I click on the add client, I get the client name in the client field and so with the salesperson and product. But when I click the add client button it opens the list screen, I give an onClickListner on the client line and it comes to the request screen without the client name in the client field
OrderMasterScreenCode:
importandroid.app.Activity;importandroid.content.Intent;importandroid.os.Bundle;importandroid.util.Log;importandroid.view.View;importandroid.widget.AdapterView;importandroid.widget.AdapterView.OnItemClickListener;importandroid.widget.Button;importandroid.widget.EditText;importandroid.widget.ListView;importbr.gestaoBd.BancoDeDados.PedidoDao;importbr.gestaoBd.BancoDeDados.PedidoItensDao;importbr.gestaoBd.Beans.Pedido;importbr.gestaoBd.Beans.ItemDoPedido;importjava.text.NumberFormat;importjava.util.ArrayList;importjava.util.Locale;publicclassCadPedidoextendsActivityimplementsAdapterView.OnItemLongClickListener,OnItemClickListener{staticPedidopedido;staticArrayList<ItemDoPedido>itensDoPedido;EditTexted1Id,ed1Cliente,ed1Vendedor,ed1Data;PedidoDaopedDao;ListViewlista;@OverridepublicvoidonCreate(Bundleicicle){super.onCreate(icicle);setContentView(R.layout.cad_pedido);ed1Id=(EditText)findViewById(R.id.cadEd1Id);ed1Cliente=(EditText)findViewById(R.id.cadEd1Cliente);ed1Vendedor=(EditText)findViewById(R.id.cadEd1Vendedor);ed1Data=(EditText)findViewById(R.id.cadEd1Data);lista=(ListView)findViewById(R.id.listview);ButtonbtAdicionarCliente=(Button)findViewById(R.id.btAdicionarCliente);btAdicionarCliente.setOnClickListener(newView.OnClickListener(){publicvoidonClick(Viewv){Intentintent=newIntent();intent.setClass(CadPedido.this,ListClientes.class);startActivity(intent);}});ButtonbtAdicionarVendedor=(Button)findViewById(R.id.btAdicionarVendedor);btAdicionarVendedor.setOnClickListener(newView.OnClickListener(){publicvoidonClick(Viewv){Intentintent=newIntent();intent.setClass(CadPedido.this,ListVendedor.class);startActivity(intent);}});ButtonbtAdicionarProduto=(Button)findViewById(R.id.btAdicionarProduto);btAdicionarProduto.setOnClickListener(newView.OnClickListener(){publicvoidonClick(Viewv){Intentintent=newIntent();intent.setClass(CadPedido.this,ListProdutos.class);startActivity(intent);}});}publicstaticPedidogetPedido(){if(pedido==null){pedido=newPedido();}returnpedido;}publicstaticArrayList<ItemDoPedido>getItensDoPedido(){if(itensDoPedido==null){Log.i("AULA", "cRIOU ITENS DO PEDIDO");
itensDoPedido = new ArrayList<ItemDoPedido>();
}
return itensDoPedido;
}
public static double getTotal() {
double total = 0.00;
Log.i("AULA", "itens adiconados =" + getItensDoPedido().size());
for (ItemDoPedido it : getItensDoPedido()) {
total += it.getQuantidade() * it.getValorUnitario();
Log.i("AULA", String.valueOf(total));
}
return total;
}
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
//Deseja excluir? = sim
getItensDoPedido().remove(position);
return true;
}
public void cancelar() {
itensDoPedido = null;
pedido = null;
finish();
}
public void gravar() {
PedidoDao pd = new PedidoDao();
pd.inserirPedido(getPedido());
PedidoItensDao pid = new PedidoItensDao();
for (ItemDoPedido it : getItensDoPedido()) {
it.setPedido(getPedido());
pid.inserirPedidoItens(it);
}
}
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
}
}
Client List Screen Code
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import br.gestaoBd.BancoDeDados.ClienteDao;
import br.gestaoBd.Beans.Cliente;
import br.gestaoBd.listaadapters.ClienteAdapter;
import java.util.ArrayList;
public class ListClientes extends Activity implements AdapterView.OnItemLongClickListener, AdapterView.OnItemClickListener {
ListView lista;
ArrayList<Cliente> clientes;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.list_clientes);
lista = (ListView) findViewById(R.id.listview);
lista.setOnItemLongClickListener(this);
lista.setOnItemClickListener(this);
atualizar(null);
}
public void atualizar(View view) {
ClienteDao cliDao = new ClienteDao();
clientes = cliDao.getListagem();
lista.setAdapter(new ClienteAdapter(getBaseContext(), clientes));
}
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
Intent cadClienteIntent = new Intent(this, CadCliente.class);
cadClienteIntent.putExtra("Cliente", clientes.get(position));
startActivity(cadClienteIntent);
return true;
}
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent cadPedidoIntent = new Intent(this, CadPedido.class);
cadPedidoIntent.putExtra("Cliente", clientes.get(position));
startActivity(cadPedidoIntent);
}
}