Ing. Honoria Reyes Macedo
1.-Agregar
las siguientes lineas al archivo strings.xml
<string name="action_EntraDoc">Captura Entrada de Documento</string>
<string
name="textVFolio">Folio:</string>
<string name="textVDoc">Tipo de Documento:</string>
<string name="spinnerDoc">Seleccione el tipo de Doc</string>
<string name="textVDocNumero">Numero de Documento:</string>
<string name="textVAsunto">Asunto:</string>
<string name="textVAcuerdo">Acuerdo:</string>
<string name="textVResol">Resolución:</string>
<string name="textVFechaDescarga">Fecha de descarga:</string>
<string name="chekUrgente">Urgente:</string>
<string name="textVAreaAsigna">Area que se asigna:</string>
<string name="textVEmpleado">Persona que se asigna:</string>
<string name="textVFechaRecibe">Fecha de recepción:</string>
<string name="textVFechaResponde">Fecha responde:</string>
<string name="textVFechaRequiere">Fecha requerida:</string>
<string name="textVTramite">Tramite</string>
<string name="btnGuardaEntrada">Guardar</string>
<string name="textVDoc">Tipo de Documento:</string>
<string name="spinnerDoc">Seleccione el tipo de Doc</string>
<string name="textVDocNumero">Numero de Documento:</string>
<string name="textVAsunto">Asunto:</string>
<string name="textVAcuerdo">Acuerdo:</string>
<string name="textVResol">Resolución:</string>
<string name="textVFechaDescarga">Fecha de descarga:</string>
<string name="chekUrgente">Urgente:</string>
<string name="textVAreaAsigna">Area que se asigna:</string>
<string name="textVEmpleado">Persona que se asigna:</string>
<string name="textVFechaRecibe">Fecha de recepción:</string>
<string name="textVFechaResponde">Fecha responde:</string>
<string name="textVFechaRequiere">Fecha requerida:</string>
<string name="textVTramite">Tramite</string>
<string name="btnGuardaEntrada">Guardar</string>
2.- Agregar el siguiente metodo a la clase TipoDocVo,java:
public String toString(){
return descripcion;
}
3.- Agregar el siguiente metodo a la clase DocumentoDAO.java
public ArrayList<TipoDocVo> ArrayListTipoDoc()throws SQLException { ArrayList<TipoDocVo> ArrayTipoDoc = new ArrayList<TipoDocVo>(); dbhelper= new DBhelper(ourcontext); database = dbhelper.getReadableDatabase(); if (database != null) { String qry= "select cvedocumento, descripcion, estatus " + " from documento order by cvedocumento"; Cursor c = database.rawQuery(qry, null); int i = 0; int cantidad = c.getCount(); int ncolumns=c.getColumnCount(); TipoDocVo DatosTipoDoc; while (c.moveToNext()) { Log.d("MyApp", "Si encontro Datos...................... "); DatosTipoDoc= new TipoDocVo(); DatosTipoDoc.setCveDocumento(c.getInt(0)); DatosTipoDoc.setDescripcion(c.getString(1)); ArrayTipoDoc.add(DatosTipoDoc); } } return ArrayTipoDoc; }
4.-
Crear un nuevo fragmento RegEntradaFragment.java
y
fragment_reg_entrada.xml
Si lo creas desde la app new +
fragment : Te crea los dos
archivos
4.1) fragment_reg_entrada.xml:
El CODIGO QUEDARIA ASI:
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.scodoc.uvm.gestiondocumentos.RegEntradaFragment" android:weightSum="1"> <ScrollView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/scrollView" android:layout_below="@+id/textView" android:layout_alignParentLeft="true" android:layout_alignParentStart="true" android:layout_alignParentRight="true" android:layout_alignParentEnd="true"> <LinearLayout android:orientation="vertical" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="center_horizontal"> <TextView style="@style/labels" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/textVFolio" android:id="@+id/textView7" /> <EditText style="@style/edits" android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/IdtextVFolio" /> <TextView style="@style/labels" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/textVDoc" android:id="@+id/IdtextVDoc" /> <Spinner style="@style/edits" android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/spinnDoc" /> <TextView style="@style/labels" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/textVDocNumero" android:id="@+id/textVDocNumero" /> <EditText style="@style/edits" android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/editTNumDoc" /> <TextView style="@style/labels" android:layout_width="72dp" android:layout_height="wrap_content" android:text="@string/textVAsunto" android:id="@+id/textView6" /> <EditText style="@style/edits" android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/edtTAsunto" /> <TextView style="@style/labels" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/textVAcuerdo" android:id="@+id/textView9" /> <EditText style="@style/edits" android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/edtTAcuerdo" /> <TextView style="@style/labels" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/textVResol" android:id="@+id/textView10" /> <EditText style="@style/edits" android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/edtTResol" /> <TextView style="@style/labels" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/textVFechaDescarga" android:id="@+id/textView11" /> <EditText style="@style/edits" android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/edtTFechaDesc" /> <CheckBox android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/chekUrgente" android:id="@+id/checkBUrge" android:checked="false" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/btnGuardaEntrada" android:id="@+id/Idbtn_guardar" android:layout_below="@+id/scrollView" android:layout_alignParentRight="true" android:layout_alignParentEnd="true" /> </LinearLayout> </ScrollView> </RelativeLayout>
4.2) RegEntradaFragment.java:
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.Spinner;
import java.util.ArrayList; public class RegEntradaFragment extends Fragment { DocumentoDAO datosBD; View viewReg; Spinner spindocsTipos; EditText NumDoc; ArrayList<TipoDocVo> AllDatos; public RegEntradaFragment() { // Required empty public constructor } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { viewReg= inflater.inflate(R.layout.fragment_reg_entrada, container, false); NumDoc = (EditText) viewReg.findViewById(R.id.editTNumDoc); spindocsTipos = (Spinner) viewReg.findViewById(R.id.spinnDoc); cargarTipoDocs(); return viewReg; } public void cargarTipoDocs() { datosBD = new DocumentoDAO(viewReg.getContext()); try { AllDatos = datosBD.ArrayListTipoDoc(); ArrayAdapter<TipoDocVo> adapter = new ArrayAdapter<TipoDocVo>(viewReg.getContext(), android.R.layout.simple_list_item_1, AllDatos); // Se llena con un ArrayList spindocsTipos.setAdapter(adapter); Log.d("MyApp", "Lleno el spinner...................... "); }catch (Exception e){ Log.d("MyApp", "Error...................... " + e); } } }
5.- El metodo onNavigationItemSelected()
de la clase InicioActivity.java
quedara asi:
(Solo
si se agrego el menu lateral con el Drawer Layout)
@SuppressWarnings("StatementWithEmptyBody")@Override
public boolean onNavigationItemSelected(MenuItem item) { Fragment fragment = null; int id = item.getItemId(); if (id == R.id.capturaId) { fragment = new RegEntradaFragment(); getSupportFragmentManager().beginTransaction() .replace(R.id.content_frame, fragment) .commit(); } else if (id == R.id.documentoId) { fragment = new TipoDocFragment(); getSupportFragmentManager().beginTransaction() .replace(R.id.content_frame, fragment) .commit(); } else if (id == R.id.AreaId) { } else if (id == R.id.asignaId) { } else if (id == R.id.imprimeId) { } else if (id == R.id.salirId) { } DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); drawer.closeDrawer(GravityCompat.START); return true; }
6.- Para agregarlo al menu lateral superior
derecho quedara asi:
6.1) En
el archivo menu_inicio_activity.xml
<?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" tools:context="com.scodoc.uvm.gestiondocumentos.InicioActivity"> <item android:id="@+id/action_InsTipoDoc" android:title="@string/action_tipoDoc" android:orderInCategory="101" app:showAsAction="never" /> <item android:id="@+id/action_consTipoDoc" android:title="@string/action_consultaTipoD" android:orderInCategory="102" app:showAsAction="never" /> <item android:id="@+id/action_capturaEntrada" android:title="@string/action_EntraDoc" android:orderInCategory="103" app:showAsAction="never" /> </menu>
6.2) En el metodo onOptionsItemSelected() del archivo InicioActivity.java
public boolean onOptionsItemSelected(MenuItem item) { Fragment fragment = null; int id = item.getItemId(); switch (id) { case R.id.action_InsTipoDoc: fragment = new TipoDocFragment(); getSupportFragmentManager().beginTransaction() .replace(R.id.content_frame, fragment) .commit(); break; case R.id.action_consTipoDoc: Toast.makeText(this, "Espere...", Toast.LENGTH_LONG).show(); Intent ir = new Intent(this, ConsultaTipoDoc.class); startActivity(ir); break; case R.id.action_capturaEntrada: fragment = new RegEntradaFragment(); getSupportFragmentManager().beginTransaction() .replace(R.id.content_frame, fragment) .commit(); break; default: return super.onOptionsItemSelected(item); }
return true;
}
ooooooooooooooooooooo oooooooooooooooooo ooooooooooooooooooooooooooooooooooo



No hay comentarios.:
Publicar un comentario