Tenho uma tela com o botao cadastrar , anterior, proximo , recuperar e atualizar
conforme abaixo:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="1">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/massa"
android:id="@+id/textView4"
android:textSize="15dp"
android:textColor="#000000"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/campoMassa" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Cobertura:"
android:id="@+id/textView5"
android:textSize="15dp"
android:textColor="#000000" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/campoCobertura"
android:inputType="none" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Recheio:"
android:id="@+id/textView6"
android:textSize="15dp"
android:textColor="#000000"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/campoRecheio"
android:inputType="none" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Formato"
android:id="@+id/textView7"
android:textSize="15dp"
android:textColor="#000000"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/campoFormato"
android:inputType="none" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Quantidade:"
android:id="@+id/textView2"
android:textSize="15dp"
android:textColor="#000000" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/campoQt"
android:inputType="text" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" Identificação:"
android:textSize="15dp"
android:textColor="#000000"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/campoId"
android:inputType="text" />
<TableLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:text="CADASTRAR"
android:id="@+id/btCadastrar"
android:layout_column="0" />
<Button
android:text="ATUALIZAR"
android:id="@+id/btAtualizar"
android:layout_column="1" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="RECUPERAR"
android:id="@+id/btRecuperar"
android:layout_column="3" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:text="ANTERIOR"
android:id="@+id/btAnterior"
android:layout_column="0" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="VOLTAR"
android:id="@+id/btVoltar"
android:layout_column="1" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="PRÓXIMO"
android:id="@+id/btProximo"
android:layout_column="3"
android:layout_gravity="right" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
</TableRow>
</TableLayout>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="LISTAR"
android:id="@+id/btListar"
android:layout_gravity="right" />
</LinearLayout>
Ao cadastrar retorna cadastrado com sucesso. A ideia é que com o botão próximo seja mostrado cadastro por cadastro na mesma tela se clicar no próximo aparece o id 1 e os dados nos campos preenchido se apertar próximo aparece o id 2 e assim sucessivamente.
btRecuperar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
registros = banco.recupera_registro();
if (registros.size() > 0) {
indiceRegistroASerExibido = 0;
campoId.setText(registros.get(indiceRegistroASerExibido).getId());
campoMassa.setText(registros.get(indiceRegistroASerExibido).getCobertura());
campoRecheio.setText(registros.get(indiceRegistroASerExibido).getRecheio());
campoFormato.setText(registros.get(indiceRegistroASerExibido).getFormato());
campoQt.setText(registros.get(indiceRegistroASerExibido).getQt());
btAnterior.setEnabled(false);
campoId.setEnabled(true);
if (registros.size() > 1) {
btProximo.setEnabled(true);
}
} else {
Toast.makeText(Pedido.this, "A consulta não retornou registros", Toast.LENGTH_LONG).show();
}
}
});
como corrigir ?