Salvar Dados de Registro

1 resposta
Pedrim_Roque

Bom dia Senhores,

Estou com um problema que no qual minha tela de cadastro não esta armazenando ou a tela de consulta n esta consultando meus dados gravado pelo usuario no registro, segue a classe dados abaixo:

por favor me ajuuudemmmm hahah
obrigado

package com.br.matella.delivery;




import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.TextView;


public class AplicationActivityMain extends Activity {

	Usuario Usuario, objUsuario, UsuarioAuxiliar;
	EditText edtNomeCompleto, edtCEP, edtEndereco, edtNumero, edtComplemento, edtEmail, edtTelefone,edtSenha;
	TextView TViewNomeCompleto, TViewCEP, TViewEndereco,TViewNumero,TViewComplemento,TViewEmail,TViewSenha,TViewTelefone;
	
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		//setContentView(R.layout.activity_aplication_activity_main);
		Log.d("Tela mae", "Foi criada");
		chamaMenuPrincipal();
		
		
	}

	public void chamaCadastro(){
		setContentView(R.layout.cadastro_usuario);
		Button btMenuPrincipal = (Button)findViewById(R.CadastroUsuario.btMenuPrincipal);
		Button btGravarDados = (Button)findViewById(R.CadastroUsuario.btGravarDados);      
		
		btMenuPrincipal.setOnClickListener(new View.OnClickListener() {
				
				@Override
				public void onClick(View v) {
					chamaMenuPrincipal();
				
					
					
				}
			});
		       
		btGravarDados.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				
				objUsuario = new Usuario();
				
				edtNomeCompleto = (EditText) findViewById(R.edtUsuario.edtNomeCompleto);
				edtCEP = (EditText) findViewById(R.edtUsuario.edtCEP);
				edtEndereco = (EditText) findViewById(R.edtUsuario.edtEndereco);
				edtNumero = (EditText) findViewById(R.edtUsuario.edtNumero);
				edtComplemento = (EditText) findViewById(R.edtUsuario.edtComplemento);
				edtEmail = (EditText) findViewById(R.edtUsuario.edtEmail);
				edtSenha = (EditText) findViewById(R.edtUsuario.edtSenha);
				edtTelefone = (EditText) findViewById(R.edtUsuario.edtTelefone);
			
				//GRAVANDO INFORMA��ES DO USU�RIO NO REGISTRO DO USUARIO
				
				objUsuario.edtNomeCompleto = edtNomeCompleto.getText().toString();
				objUsuario.edtCEP = edtCEP.getText().toString();
				objUsuario.edtEndereco = edtEndereco.getText().toString();
				objUsuario.edtNumero = edtNumero.getText().toString();
				objUsuario.edtComplemento = edtComplemento.getText().toString();
				objUsuario.edtEmail = edtEmail.getText().toString();
				objUsuario.edtSenha = edtSenha.getText().toString();
				objUsuario.edtTelefone = edtTelefone.getText().toString();
				
				
				
			}
		});
		
	}
	
     public void chamaConsulta(){
		setContentView(R.layout.consultar_usuarios);
    	 Button btVoltar = (Button)findViewById(R.USRCadastrados.btVoltar);
    	
    	    TextView TViewNomeCompleto = (TextView) findViewById(R.TviewUSRCadastrados.TViewNomeCompleto);
    		TextView TViewCEP = (TextView) findViewById(R.TviewUSRCadastrados.TViewCEP);
    		TextView TViewEndereco = (TextView) findViewById(R.TviewUSRCadastrados.TViewEndereco);
    		TextView TViewNumero = (TextView) findViewById(R.TviewUSRCadastrados.TViewNumero);
    		TextView TViewComplemento = (TextView) findViewById(R.TviewUSRCadastrados.TViewComplemento);
    		TextView TViewEmail = (TextView) findViewById(R.TviewUSRCadastrados.TViewEmail);
    		TextView TViewSenha = (TextView) findViewById(R.TviewUSRCadastrados.TViewSenha);
    		TextView TViewTelefone = (TextView) findViewById(R.TviewUSRCadastrados.TViewTelefone);
    		
    		//INSERINDO OS VALORES CADASTRADOS NA CLASSE CADASTROUSUARIO.CLASS NOS CAMPOS
    		
    		    		
    		TViewNomeCompleto.setText(objUsuario.TViewNomeCompleto);
    		TViewCEP.setText(objUsuario.TViewCEP);
    		TViewEndereco.setText(objUsuario.TViewEndereco);
    		TViewNumero.setText(objUsuario.TViewNumero);
    		TViewComplemento.setText(objUsuario.TViewComplemento);
    		TViewEmail.setText(objUsuario.TViewEmail);
    		TViewSenha.setText(objUsuario.TViewSenha);
    		TViewTelefone.setText(objUsuario.TViewTelefone);
    	 
    	 
    	 btVoltar.setOnClickListener(new View.OnClickListener() {
			
    	        	@Override
					public void onClick(View v) {
					   chamaMenuPrincipal();
						
					}
    	        });
    	 	
     }
     public void chamaMenuPrincipal(){
    	 setContentView(R.layout.activity_aplication_activity_main);
    	 ImageButton btNovoCadastro = (ImageButton)findViewById(R.MainAplication.btNovoCadastro);
    	 ImageButton btConsulta = (ImageButton)findViewById(R.MainAplication.btConsulta);
    	 
    	   btNovoCadastro.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
                  chamaCadastro(); //chama tela de cadastro ao clicar
				
			}
		});
    
    	   btConsulta.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				chamaConsulta();  //chama tela de consulta usuarios
				
			}
		});
     }

}

Segue a tela cadastro_activity

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="wrap_content"
    android:layout_height="fill_parent"
    android:background="@color/Laranja"
    tools:context=".AplicationActivityMain" >

    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="323dp"
        android:layout_height="match_parent"
        android:orientation="vertical" >

        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_margin="10dp"
            android:layout_marginLeft="50dp"
            android:layout_marginRight="50dp"
            android:text="Informe os dados para Cadastro"
            android:textColor="@color/cinza"
            android:textSize="15dp" />

        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="20dp"
            android:layout_marginRight="20dp"
            android:text="Nome Completo" />

        <EditText
            android:id="@+edtUsuario/edtNomeCompleto"
            android:layout_width="288dp"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp" />
        android:hint="Nome Completo" />

        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="20dp"
            android:layout_marginRight="20dp"
            android:text="CEP" />

        <EditText
            android:id="@+edtUsuario/edtCEP"
            android:layout_width="288dp"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp" />
        android:hint="CEP"
        />

        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="20dp"
            android:layout_marginRight="20dp"
            android:text="Endereco" />

        <EditText
            android:id="@+edtUsuario/edtEndereco"
            android:layout_width="288dp"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp" />
        android:hint="Endereco"/>

        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="20dp"
            android:layout_marginRight="20dp"
            android:text="Numero" />

        <EditText
            android:id="@+edtUsuario/edtNumero"
            android:layout_width="288dp"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp" />
        android:hint="Numero"  />

        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="20dp"
            android:layout_marginRight="20dp"
            android:text="Complemento" />

        <EditText
            android:id="@+edtUsuario/edtComplemento"
            android:layout_width="288dp"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp" />
        android:hint="Complemento"  />

        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="20dp"
            android:layout_marginRight="20dp"
            android:text="E-mail" />

        <EditText
            android:id="@+edtUsuario/edtEmail"
            android:layout_width="288dp"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp" />
        android:hint="E-mail"  />

        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="20dp"
            android:layout_marginRight="20dp"
            android:text="Senha" />

        <EditText
            android:id="@+edtUsuario/edtSenha"
            android:layout_width="288dp"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp" />
        android:hint="Telefone"  />

        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="20dp"
            android:layout_marginRight="20dp"
            android:text="Telefone" />

        <EditText
            android:id="@+edtUsuario/edtTelefone"
            android:layout_width="288dp"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp" />
        android:hint="Telefone"  />

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal" >

            <Button
                android:id="@+CadastroUsuario/btMenuPrincipal"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Menu Principal" />

            <Button
                android:id="@+CadastroUsuario/btGravarDados"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="70dp"
                android:layout_marginRight="70dp"
                android:text="Gravar Dados" />
        </LinearLayout>

        <LinearLayout
            android:id="@+id/llRodape"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_alignParentLeft="true"
            android:orientation="vertical" >

            <TextView
                android:id="@+id/tvRodape"
                style="@style/TitleBarText"
                android:layout_width="fill_parent"
                android:background="@color/cinza"
                android:text="@string/rodape"
                android:textSize="14sp" />
        </LinearLayout>
    </LinearLayout>

</ScrollView>

Segue a tela que chama a tela de cadastro activity:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="wrap_content"
    android:layout_height="fill_parent"
    android:background="@color/Laranja"
    tools:context=".AplicationActivityMain" >

    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="323dp"
        android:layout_height="match_parent"
        android:orientation="vertical" >

        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_margin="10dp"
            android:layout_marginLeft="50dp"
            android:layout_marginRight="50dp"
            android:text="Clientes Cadastrados"
            android:textColor="@color/cinza"
            android:textSize="15dp" />

        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="20dp"
            android:layout_marginRight="20dp"
            android:text="Nome" />

        <TextView
            android:id="@+TviewUSRCadastrados/TViewNomeCompleto"
            android:layout_width="288dp"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp" 
        />

        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="20dp"
            android:layout_marginRight="20dp"
            android:text="CEP" />

        <TextView
            android:id="@+TviewUSRCadastrados/TViewCEP"
            android:layout_width="288dp"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp" 
      
        />

        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="20dp"
            android:layout_marginRight="20dp"
            android:text="Endereco" />

        <TextView
            android:id="@+TviewUSRCadastrados/TViewEndereco"
            android:layout_width="288dp"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp" 
        />

        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="20dp"
            android:layout_marginRight="20dp"
            android:text="Numero" />

        <TextView
            android:id="@+TviewUSRCadastrados/TViewNumero"
            android:layout_width="288dp"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp" 
         />

        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="20dp"
            android:layout_marginRight="20dp"
            android:text="Complemento" />

        <TextView
            android:id="@+TviewUSRCadastrados/TViewComplemento"
            android:layout_width="288dp"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp" 
          />

        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="20dp"
            android:layout_marginRight="20dp"
            android:text="E-mail" />

        <TextView
            android:id="@+TviewUSRCadastrados/TViewEmail"
            android:layout_width="288dp"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp" 
        />

        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="20dp"
            android:layout_marginRight="20dp"
            android:text="Senha" />

        <TextView
            android:id="@+TviewUSRCadastrados/TViewSenha"
            android:layout_width="288dp"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp" 
          />

        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="20dp"
            android:layout_marginRight="20dp"
            android:text="Telefone" />

        <TextView
            android:id="@+TviewUSRCadastrados/TViewTelefone"
            android:layout_width="288dp"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp" 
          />

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal" >

            <Button
                android:id="@+USRCadastrados/btVoltar"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Voltar" />

            
        </LinearLayout>

        <LinearLayout
            android:id="@+id/llRodape"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_alignParentLeft="true"
            android:orientation="vertical" >

            <TextView
                android:id="@+id/tvRodape"
                style="@style/TitleBarText"
                android:layout_width="fill_parent"
                android:background="@color/cinza"
                android:text="@string/rodape"
                android:textSize="14sp" />
        </LinearLayout>
    </LinearLayout>

</ScrollView>

ajudee me???

1 Resposta

F

Bom pelo seu código parece que não há existência de CRUD.

já há exemplos no fórum, se não encontrar me avisa!

Criado 12 de dezembro de 2012
Ultima resposta 19 de dez. de 2012
Respostas 1
Participantes 2