Nombre Ruben Dario Velasquez Mamani Ci 8318511 LP: XML Linearlayout

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 20

Nombre Ruben Dario Velasquez Mamani

CI 8318511 LP

Vista
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Factura"
android:textAppearance="?android:attr/textAppearanceLarge" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >

<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="NIT"
android:textAppearance="?android:attr/textAppearanceLarge"
/>

<EditText
android:id="@+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10" >

<requestFocus />
</EditText>

</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >

<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Apellido"
android:textAppearance="?android:attr/textAppearanceLarge"
/>

<EditText
android:id="@+id/editText2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10" />

</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >

<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TOTAL"
android:textAppearance="?android:attr/textAppearanceLarge"
/>

<EditText
android:id="@+id/editText3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10" />

</LinearLayout>

<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="regresar"
android:text="REGRESAR" />

</LinearLayout>

<?xml version="1.0" encoding="utf-8"?>


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

<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />

<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="retornar"
android:text="RETORNAR" />

</LinearLayout>

<?xml version="1.0" encoding="utf-8"?>


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

<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Datos para la factura"
android:textAppearance="?android:attr/textAppearanceLarge" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >

<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="NIT >"
android:textAppearance="?android:attr/textAppearanceLarge"
/>

<EditText
android:id="@+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10" >

<requestFocus />
</EditText>

</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >

<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="CI >"
android:textAppearance="?android:attr/textAppearanceLarge"
/>

<EditText
android:id="@+id/editText2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10" />

</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >

<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Apellidos"
android:textAppearance="?android:attr/textAppearanceLarge"
/>

<EditText
android:id="@+id/editText3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10" />

</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >

<Button
android:id="@+id/button1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="generarFactura"
android:text="GENERAR FACTURA" />

</LinearLayout>

<Button
android:id="@+id/button2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="REGRESAR" />

</LinearLayout>

contralador

package com.example.uguesas;

import android.app.Activity;

import android.content.Intent;

import android.os.Bundle;

import android.view.Menu;

import android.view.View;

import android.widget.EditText;

import android.widget.ImageView;

import android.widget.TextView;
public class MainActivity extends Activity {

int ug[] = {R.drawable.hconfideitos, R.drawable.hconhuevo,

R.drawable.hdoble, R.drawable.hgemelas, R.drawable.hmariajuana,

R.drawable.hmediokilo, R.drawable.hnormal,R.drawable.hpollo,

R.drawable.hvegetal};

String th[] = {"H.c/Fideitos","H. c/Huevo","H. Doble","H. Gemelas",

"H. MariaJuana","H.1/2 Kilo","H. Normal","H. Pollo","H. Vegerianas"};

Double ph[] = {15.0,13.0,18.0,21.0,25.0,18.0,12.0,12.0,15.0};

int pedidos[] ={0,0,0,0,0,0,0,0,0};

Double total[]= {0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0};

int Indice = 0;

Double cant = 0.0;

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

TextView q = (TextView) findViewById(R.id.textView1);

q.setText(th[Indice]+" "+ph[Indice]);

public void anterior(View vista){

ImageView pug = (ImageView) findViewById(R.id.imageView1);

TextView t = (TextView) findViewById(R.id.textView1);

EditText pcan =(EditText) findViewById(R.id.editText1);

Indice --;

if(Indice<0) Indice=8;

pug.setImageResource(ug[Indice]);

t.setText(th[Indice]+" "+ph[Indice]);

pcan.setText(pedidos[Indice]+"");
}

public void siguiente(View vista){

ImageView pug = (ImageView) findViewById(R.id.imageView1);

TextView t= (TextView) findViewById(R.id.textView1);

EditText pcan =(EditText) findViewById(R.id.editText1);

EditText pcan1 =(EditText) findViewById(R.id.editText2);

Indice ++;

if(Indice==9) Indice=0;

pug.setImageResource(ug[Indice]);

t.setText(th[Indice]+" "+ph[Indice]);

pcan.setText(pedidos[Indice]+"");

public void comprar(View vista){

EditText pcan =(EditText) findViewById(R.id.editText1);

EditText pcan1 =(EditText) findViewById(R.id.editText2);

pedidos[Indice]++;

total[Indice] = total[Indice]+ph[Indice];

cant= cant + ph[Indice];

pcan1.setText(cant+"");

pcan.setText(pedidos[Indice]+"");

public void devolver(View vista){

EditText pcan =(EditText) findViewById(R.id.editText1);

EditText pcan1 =(EditText) findViewById(R.id.editText2);

if(pedidos[Indice]!=0){

pedidos[Indice]--;

total[Indice] = total[Indice] = ph[Indice];

pcan.setText(pedidos[Indice]+"");
cant= cant - ph[Indice];

pcan1.setText(cant+"");

public void facturacion(View vista){

int ped ;

String ti;

double t;

ped=pedidos[0];

int totalPedidos = 0;

Intent fac = new Intent(this,FacturaActivity.class);

totalPedidos = totalPedidos+ped;

fac.putExtra("p0", ped);

ped= pedidos[1];

totalPedidos = totalPedidos+ped;

fac.putExtra("p1", ped);

ped=pedidos[2];

totalPedidos = totalPedidos+ped;

fac.putExtra("p2", ped);

ped=pedidos[3];

totalPedidos = totalPedidos+ped;

fac.putExtra("p3", ped);

ped=pedidos[4];

totalPedidos = totalPedidos+ped;

fac.putExtra("p4", ped);

ped=pedidos[5];

totalPedidos = totalPedidos+ped;

fac.putExtra("p5", ped);

ped=pedidos[6];

totalPedidos = totalPedidos+ped;

fac.putExtra("p6", ped);
ped=pedidos[7];

totalPedidos = totalPedidos+ped;

fac.putExtra("p7", ped);

ped=pedidos[8];

totalPedidos = totalPedidos+ped;

fac.putExtra("p8", ped);

ti=th[0];

fac.putExtra("pt0", ti);

ti=th[1];

fac.putExtra("pt1", ti);

ti=th[2];

fac.putExtra("pt2", ti);

ti=th[3];

fac.putExtra("pt3", ti);

ti=th[4];

fac.putExtra("pt4", ti);

ti=th[5];

fac.putExtra("pt5", ti);

ti=th[6];

fac.putExtra("pt6", ti);

ti=th[7];

fac.putExtra("pt7", ti);

ti=th[8];

fac.putExtra("pt8", ti);

t=total[0];

fac.putExtra("ptt0", t);

t=total[1];
fac.putExtra("ptt1", t);

t=total[2];

fac.putExtra("ptt2", t);

t=total[3];

fac.putExtra("ptt3", t);

t=total[4];

fac.putExtra("ptt4", t);

t=total[5];

fac.putExtra("ptt5", t);

t=total[6];

fac.putExtra("ptt6", t);

t=total[7];

fac.putExtra("ptt7", t);

t=total[8];

fac.putExtra("ptt8", t);

fac.putExtra("cat", cant);

startActivity(fac);

Intent g = new Intent(this,ConfacturaActivity.class);

g.putExtra("cantidad", totalPedidos);

@Override

public boolean onCreateOptionsMenu(Menu menu) {

// Inflate the menu; this adds items to the action bar if it is present.

getMenuInflater().inflate(R.menu.main, menu);
return true;

Facturacompra
package com.example.uguesas;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.EditText;

public class FacturacompraActivity extends Activity {


int pa1=9;
@Override

protected void onCreate(Bundle savedInstanceState) {


super.onCreate(savedInstanceState);
setContentView(R.layout.activity_facturacompra);
Bundle pa= getIntent().getExtras();
EditText p1 = (EditText) findViewById(R.id.editText1);
EditText p2 = (EditText) findViewById(R.id.editText2);
EditText p3 = (EditText) findViewById(R.id.editText3);
p3.setText(pa1+"");
p1.setText(pa.getInt("nit")+"");
p2.setText(pa.getString("apellido"));
}
public void regredar(View vista){
finish();
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it
is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}

}
FActuta

package com.example.uguesas;

import android.app.Activity;

import android.content.Intent;

import android.os.Bundle;
import android.view.Menu;

import android.view.View;

import android.widget.EditText;

public class FacturaActivity extends Activity {

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_factura);

Bundle par = getIntent().getExtras();

EditText t0 = (EditText) findViewById(R.id.editText1);

EditText t1 = (EditText) findViewById(R.id.editText4);

EditText t2 = (EditText) findViewById(R.id.editText8);

EditText t3 = (EditText) findViewById(R.id.editText11);

EditText t4 = (EditText) findViewById(R.id.editText13);

EditText t5 = (EditText) findViewById(R.id.editText16);

EditText t6 = (EditText) findViewById(R.id.editText19);

EditText t7 = (EditText) findViewById(R.id.editText23);

EditText t8 = (EditText) findViewById(R.id.editText26);

t0.setText(par.getInt("p0")+"");

t1.setText(par.getInt("p1")+"");

t2.setText(par.getInt("p2")+"");

t3.setText(par.getInt("p3")+"");

t4.setText(par.getInt("p4")+"");

t5.setText(par.getInt("p5")+"");

t6.setText(par.getInt("p6")+"");

t7.setText(par.getInt("p7")+"");

t8.setText(par.getInt("p8")+"");
EditText tt0 = (EditText) findViewById(R.id.editText2);

EditText tt1 = (EditText) findViewById(R.id.editText5);

EditText tt2 = (EditText) findViewById(R.id.editText7);

EditText tt3 = (EditText) findViewById(R.id.editText10);

EditText tt4 = (EditText) findViewById(R.id.editText14);

EditText tt5 = (EditText) findViewById(R.id.editText17);

EditText tt6 = (EditText) findViewById(R.id.editText20);

EditText tt7 = (EditText) findViewById(R.id.editText22);

EditText tt8 = (EditText) findViewById(R.id.editText25);

EditText ttt0 = (EditText) findViewById(R.id.editText3);

EditText ttt1 = (EditText) findViewById(R.id.editText6);

EditText ttt2 = (EditText) findViewById(R.id.editText9);

EditText ttt3 = (EditText) findViewById(R.id.editText12);

EditText ttt4 = (EditText) findViewById(R.id.editText15);

EditText ttt5 = (EditText) findViewById(R.id.editText18);

EditText ttt6 = (EditText) findViewById(R.id.editText21);

EditText ttt7 = (EditText) findViewById(R.id.editText24);

EditText ttt8 = (EditText) findViewById(R.id.editText27);

tt0.setText(par.getString("pt0")+"");

tt1.setText(par.getString("pt1")+"");

tt2.setText(par.getString("pt2")+"");

tt3.setText(par.getString("pt3")+"");

tt4.setText(par.getString("pt4")+"");

tt5.setText(par.getString("pt5")+"");

tt6.setText(par.getString("pt6")+"");
tt7.setText(par.getString("pt7")+"");

tt8.setText(par.getString("pt8")+"");

ttt0.setText(par.getInt("p0")*15+"");

ttt1.setText(par.getInt("p1")*13+"");

ttt2.setText(par.getInt("p2")*18+"");

ttt3.setText(par.getInt("p3")*21+"");

ttt4.setText(par.getInt("p4")*25+"");

ttt5.setText(par.getInt("p5")*18+"");

ttt6.setText(par.getInt("p6")*12+"");

ttt7.setText(par.getInt("p7")*12+"");

ttt8.setText(par.getInt("p8")*15+"");

EditText cat1 = (EditText) findViewById(R.id.editText28);

cat1.setText(par.getDouble("cat")+"");

public void regresar(View vista){

finish();

public void confirmar(View vista){

Intent confFactura = new Intent(this,ConfacturaActivity.class);

startActivity(confFactura);

}
@Override

public boolean onCreateOptionsMenu(Menu menu) {

// Inflate the menu; this adds items to the action bar if it is present.

getMenuInflater().inflate(R.menu.main, menu);

return true;

Confactura

package com.example.uguesas;

import android.app.Activity;

import android.content.Intent;

import android.os.Bundle;

import android.view.Menu;

import android.view.View;

import android.widget.EditText;

import android.widget.TextView;

public class ConfacturaActivity extends Activity {

String vf[] = {"","",""};

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_confactura);

public void generarFactura(View vista){

Bundle par = getIntent().getExtras();

EditText p1 = (EditText) findViewById(R.id.editText1);


EditText p2 = (EditText) findViewById(R.id.editText2);

EditText p3 = (EditText) findViewById(R.id.editText3);

TextView p4 = (TextView) findViewById(R.id.textView2);

TextView p5 = (TextView) findViewById(R.id.textView3);

String pp3 = p3.getText().toString();

Intent en= new Intent(this,FacturacompraActivity.class);

if(p1.equals("")){

int fac = Integer.parseInt(p2.getText().toString());

p4.setText("0");

p5.setText(fac+"");

else{

int nit = Integer.parseInt(p1.getText().toString());

en.putExtra("nit", nit);

en.putExtra("apellido", pp3);

p4.setText(nit+"");

p5.setText("0");

startActivity(en);

@Override

public boolean onCreateOptionsMenu(Menu menu) {


// Inflate the menu; this adds items to the action bar if it is present.

getMenuInflater().inflate(R.menu.main, menu);

return true;

Android fanifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.uguesas"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />

<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.uguesas.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category
android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.uguesas.FacturacionActivity"
android:label="@string/app_name" >

</activity>
<activity
android:name="com.example.uguesas.FacturaActivity"
android:label="@string/app_name" >

</activity>
<activity
android:name="com.example.uguesas.ConfacturaActivity"
android:label="@string/app_name" >

</activity>
<activity
android:name="com.example.uguesas.FacturacompraActivity"
android:label="@string/app_name" >
</activity>
</application>

</manifest>

Imágenes

You might also like