Funcionando con productos y totales :3
This commit is contained in:
4
app/proguard-rules.pro
vendored
4
app/proguard-rules.pro
vendored
@@ -6,7 +6,7 @@
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# and specify the fully qualified class nombre to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
@@ -17,5 +17,5 @@
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
# hide the original source file nombre.
|
||||
#-renamesourcefileattribute SourceFile
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="xyz.danielcortes.androidsqlite">
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
@@ -8,15 +9,9 @@
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme">
|
||||
<activity
|
||||
android:name=".UpdateDeleteActivity"
|
||||
android:label="Usuario" />
|
||||
<activity
|
||||
android:name=".AddUserActivity"
|
||||
android:label="Ingresar Nombre y Hobby" />
|
||||
<activity
|
||||
android:name=".GetAllUsersActivity"
|
||||
android:label="Usuarios">
|
||||
<activity android:name=".UpdateDeleteActivity" />
|
||||
<activity android:name=".AddProductoActivity" />
|
||||
<activity android:name=".GetAllProductosActivity">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
|
||||
@@ -2,7 +2,6 @@ package xyz.danielcortes.androidsqlite;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
@@ -10,25 +9,28 @@ import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.Toast;
|
||||
|
||||
public class AddUserActivity extends AppCompatActivity {
|
||||
public class AddProductoActivity extends AppCompatActivity {
|
||||
private DatabaseHelper databaseHelper;
|
||||
|
||||
private Button grabarButton;
|
||||
private EditText nombreText;
|
||||
private EditText hobbyText;
|
||||
private EditText precioText;
|
||||
private EditText cantidadText;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_add_user);
|
||||
setContentView(R.layout.activity_add_producto);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
getSupportActionBar().setDisplayShowHomeEnabled(true);
|
||||
getSupportActionBar().setTitle("Agregar Producto");
|
||||
|
||||
databaseHelper = new DatabaseHelper(this);
|
||||
|
||||
grabarButton = findViewById(R.id.grabarButton);
|
||||
nombreText = findViewById(R.id.nombreText);
|
||||
hobbyText = findViewById(R.id.hobbyText);
|
||||
cantidadText = findViewById(R.id.cantidadText);
|
||||
precioText = findViewById(R.id.precioText);
|
||||
|
||||
grabarButton.setOnClickListener(onSave());
|
||||
}
|
||||
@@ -36,14 +38,13 @@ public class AddUserActivity extends AppCompatActivity {
|
||||
private View.OnClickListener onSave() {
|
||||
return new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
databaseHelper.addUserDetail(
|
||||
databaseHelper.addProducto(
|
||||
nombreText.getText().toString(),
|
||||
hobbyText.getText().toString()
|
||||
Integer.valueOf(cantidadText.getText().toString()),
|
||||
Integer.valueOf(precioText.getText().toString())
|
||||
);
|
||||
nombreText.setText("");
|
||||
hobbyText.setText("");
|
||||
Toast.makeText(
|
||||
AddUserActivity.this,
|
||||
AddProductoActivity.this,
|
||||
"Datos grabados!",
|
||||
Toast.LENGTH_LONG
|
||||
).show();
|
||||
@@ -12,54 +12,60 @@ import java.util.List;
|
||||
public class CustomAdapter extends BaseAdapter {
|
||||
|
||||
private Context context;
|
||||
private List<User> users;
|
||||
private List<Producto> productos;
|
||||
|
||||
public CustomAdapter(Context context, List<User> users) {
|
||||
public CustomAdapter(Context context, List<Producto> productos) {
|
||||
this.context = context;
|
||||
this.users = users;
|
||||
this.productos = productos;
|
||||
}
|
||||
|
||||
public void changeList(List<User> users) {
|
||||
this.users = users;
|
||||
public void changeList(List<Producto> productos) {
|
||||
this.productos = productos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return users.size();
|
||||
return productos.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(int i) {
|
||||
return users.get(i);
|
||||
return productos.get(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int i) {
|
||||
return users.get(i).getId();
|
||||
return productos.get(i).getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View view, ViewGroup parent) {
|
||||
public View getView(int i, View view, ViewGroup parent) {
|
||||
ViewHolder viewHolder;
|
||||
|
||||
if(view == null) {
|
||||
viewHolder = new ViewHolder();
|
||||
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
view = inflater.inflate(R.layout.list_view, null, true);
|
||||
viewHolder.nameText = view.findViewById(R.id.nameText);
|
||||
viewHolder.hobbyText = view.findViewById(R.id.hobbyText);
|
||||
viewHolder.nombreText = view.findViewById(R.id.nombreText);
|
||||
viewHolder.cantidadText = view.findViewById(R.id.cantidadText);
|
||||
viewHolder.precioText = view.findViewById(R.id.precioText);
|
||||
viewHolder.totalText = view.findViewById(R.id.totalText);
|
||||
view.setTag(viewHolder);
|
||||
}else{
|
||||
viewHolder = (ViewHolder)view.getTag();
|
||||
}
|
||||
|
||||
viewHolder.nameText.setText("Nombre: " + users.get(position).getName());
|
||||
viewHolder.hobbyText.setText("Hobby: " + users.get(position).getHobby());
|
||||
Producto producto = productos.get(i);
|
||||
|
||||
viewHolder.nombreText.setText("Nombre: " + producto.getNombre());
|
||||
viewHolder.cantidadText.setText("Cantidad: " + producto.getCantidad());
|
||||
viewHolder.precioText.setText("Precio: " + producto.getPrecio());
|
||||
viewHolder.totalText.setText("Total: " + (producto.getPrecio() * producto.getCantidad()));
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
private class ViewHolder {
|
||||
protected TextView nameText, hobbyText;
|
||||
protected TextView nombreText, cantidadText, precioText, totalText;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,69 +12,81 @@ import java.util.List;
|
||||
|
||||
public class DatabaseHelper extends SQLiteOpenHelper {
|
||||
|
||||
public static String DATABASE_NAME = "user_database";
|
||||
private static final int DATABASE_VERSION = 1;
|
||||
private static final String TABLE_USER = "users";
|
||||
private static final String KEY_ID = "id";
|
||||
private static final String KEY_FIRSTNAME = "name";
|
||||
private static final String KEY_HOBBY = "hobby";
|
||||
|
||||
private static final String CREATE_TABLE_STUDENTS = "CREATE TABLE " + TABLE_USER + "(" + KEY_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + KEY_FIRSTNAME + " TEXT, " + KEY_HOBBY + " TEXT );";
|
||||
|
||||
public DatabaseHelper(Context context) {
|
||||
super(context, DATABASE_NAME, null, DATABASE_VERSION);
|
||||
|
||||
Log.d("Database", CREATE_TABLE_STUDENTS);
|
||||
super(context, "productos_db", null, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(SQLiteDatabase db) {
|
||||
db.execSQL(CREATE_TABLE_STUDENTS);
|
||||
String sql = new StringBuilder()
|
||||
.append("create table producto (")
|
||||
.append("id integer primary key autoincrement,")
|
||||
.append("nombre text not null,")
|
||||
.append("cantidad integer not null default 1,")
|
||||
.append("precio integer not null default 1)")
|
||||
.toString();
|
||||
db.execSQL(sql);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
||||
db.execSQL("DROP TABLE IF EXISTS '" + TABLE_USER + "'");
|
||||
db.execSQL("drop table if exists producto");
|
||||
onCreate(db);
|
||||
}
|
||||
|
||||
public boolean addUserDetail(String name, String hobby) {
|
||||
public boolean addProducto(String nombre, int cantidad, int precio) {
|
||||
SQLiteDatabase db = this.getWritableDatabase();
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(KEY_FIRSTNAME, name);
|
||||
values.put(KEY_HOBBY, hobby);
|
||||
return db.insert(TABLE_USER, null, values) == 1;
|
||||
values.put("nombre", nombre);
|
||||
values.put("cantidad", cantidad);
|
||||
values.put("precio", precio);
|
||||
return db.insert("producto", null, values) == 1;
|
||||
}
|
||||
|
||||
public List<User> getAllUsers() {
|
||||
List<User> users= new ArrayList<>();
|
||||
String selectQuery = "SELECT * FROM " + TABLE_USER;
|
||||
public List<Producto> getAllProductos() {
|
||||
List<Producto> productos = new ArrayList<>();
|
||||
|
||||
String sql = "select * from producto";
|
||||
SQLiteDatabase db = this.getReadableDatabase();
|
||||
Cursor cursor = db.rawQuery(selectQuery, null);
|
||||
Cursor cursor = db.rawQuery(sql, null);
|
||||
|
||||
if (cursor.moveToFirst()) {
|
||||
do {
|
||||
User user = new User();
|
||||
user.setId(cursor.getInt(cursor.getColumnIndex(KEY_ID)));
|
||||
user.setName(cursor.getString(cursor.getColumnIndex(KEY_FIRSTNAME)));
|
||||
user.setHobby(cursor.getString(cursor.getColumnIndex(KEY_HOBBY)));
|
||||
users.add(user);
|
||||
Producto producto = new Producto();
|
||||
producto.setId(cursor.getInt(cursor.getColumnIndex("id")));
|
||||
producto.setNombre(cursor.getString(cursor.getColumnIndex("nombre")));
|
||||
producto.setCantidad(cursor.getInt(cursor.getColumnIndex("cantidad")));
|
||||
producto.setPrecio(cursor.getInt(cursor.getColumnIndex("precio")));
|
||||
productos.add(producto);
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
|
||||
cursor.close();
|
||||
return users;
|
||||
return productos;
|
||||
}
|
||||
|
||||
public int updateUser(int id, String name, String hobby) {
|
||||
public long getTotal() {
|
||||
String sql = "select sum(precio * cantidad) as total from producto";
|
||||
SQLiteDatabase db = this.getReadableDatabase();
|
||||
Cursor cursor = db.rawQuery(sql, null);
|
||||
if(cursor.moveToFirst()) {
|
||||
return cursor.getLong(cursor.getColumnIndex("total"));
|
||||
}else{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public int updateProducto(int id, String name, int cantidad, int precio) {
|
||||
SQLiteDatabase db = this.getWritableDatabase();
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(KEY_FIRSTNAME, name);
|
||||
values.put(KEY_HOBBY, hobby);
|
||||
return db.update(TABLE_USER, values, KEY_ID + " = ?", new String[]{String.valueOf(id)});
|
||||
values.put("nombre", name);
|
||||
values.put("cantidad", cantidad);
|
||||
values.put("precio", precio);
|
||||
return db.update("producto", values, "id = ?", new String[]{String.valueOf(id)});
|
||||
}
|
||||
|
||||
public void deleteUser(int id) {
|
||||
public void deleteProducto(int id) {
|
||||
SQLiteDatabase db = this.getWritableDatabase();
|
||||
db.delete(TABLE_USER, KEY_ID + " = ?", new String[]{String.valueOf(id)});
|
||||
db.delete("producto", "id = ?", new String[]{String.valueOf(id)});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,45 +3,46 @@ package xyz.danielcortes.androidsqlite;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class GetAllUsersActivity extends AppCompatActivity {
|
||||
public class GetAllProductosActivity extends AppCompatActivity {
|
||||
private ListView listView;
|
||||
private Button agregarButton;
|
||||
private List<User> users;
|
||||
private TextView totalText;
|
||||
private List<Producto> productos;
|
||||
private CustomAdapter customAdapter;
|
||||
private DatabaseHelper databaseHelper;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_get_all_users);
|
||||
setContentView(R.layout.activity_get_all_productos);
|
||||
getSupportActionBar().setTitle("Lista de compra");
|
||||
|
||||
listView = findViewById(R.id.listView);
|
||||
totalText = findViewById(R.id.totalText);
|
||||
agregarButton = findViewById(R.id.agregarButton);
|
||||
|
||||
databaseHelper = new DatabaseHelper(this);
|
||||
users = databaseHelper.getAllUsers();
|
||||
customAdapter = new CustomAdapter(this, users);
|
||||
productos = databaseHelper.getAllProductos();
|
||||
customAdapter = new CustomAdapter(this, productos);
|
||||
listView.setAdapter(customAdapter);
|
||||
totalText.setText("Total: " + databaseHelper.getTotal());
|
||||
|
||||
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
Intent intent = new Intent(GetAllUsersActivity.this, UpdateDeleteActivity.class);
|
||||
intent.putExtra("user", users.get(position));
|
||||
Intent intent = new Intent(GetAllProductosActivity.this, UpdateDeleteActivity.class);
|
||||
intent.putExtra("producto", productos.get(position));
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
@@ -49,7 +50,7 @@ public class GetAllUsersActivity extends AppCompatActivity {
|
||||
agregarButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(GetAllUsersActivity.this, AddUserActivity.class);
|
||||
Intent intent = new Intent(GetAllProductosActivity.this, AddProductoActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
@@ -58,8 +59,9 @@ public class GetAllUsersActivity extends AppCompatActivity {
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
users = databaseHelper.getAllUsers();
|
||||
customAdapter.changeList(users);
|
||||
productos = databaseHelper.getAllProductos();
|
||||
customAdapter.changeList(productos);
|
||||
customAdapter.notifyDataSetChanged();
|
||||
totalText.setText("Total: " + databaseHelper.getTotal());
|
||||
}
|
||||
}
|
||||
42
app/src/main/java/xyz/danielcortes/androidsqlite/Producto.java
Executable file
42
app/src/main/java/xyz/danielcortes/androidsqlite/Producto.java
Executable file
@@ -0,0 +1,42 @@
|
||||
package xyz.danielcortes.androidsqlite;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class Producto implements Serializable {
|
||||
private int id;
|
||||
private String nombre;
|
||||
private int cantidad;
|
||||
private int precio;
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getNombre() {
|
||||
return nombre;
|
||||
}
|
||||
|
||||
public void setNombre(String nombre) {
|
||||
this.nombre = nombre;
|
||||
}
|
||||
|
||||
public int getCantidad() {
|
||||
return cantidad;
|
||||
}
|
||||
|
||||
public void setCantidad(int cantidad) {
|
||||
this.cantidad = cantidad;
|
||||
}
|
||||
|
||||
public int getPrecio() {
|
||||
return precio;
|
||||
}
|
||||
|
||||
public void setPrecio(int precio) {
|
||||
this.precio = precio;
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,6 @@ import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
@@ -13,9 +12,11 @@ import android.widget.EditText;
|
||||
import android.widget.Toast;
|
||||
|
||||
public class UpdateDeleteActivity extends AppCompatActivity {
|
||||
private User user;
|
||||
private Producto producto;
|
||||
private EditText nombreText;
|
||||
private EditText hobbyText;
|
||||
private EditText precioText;
|
||||
private EditText cantidadText;
|
||||
|
||||
private Button updateButton;
|
||||
private Button deleteButton;
|
||||
|
||||
@@ -27,17 +28,21 @@ public class UpdateDeleteActivity extends AppCompatActivity {
|
||||
setContentView(R.layout.activity_update_delete);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
getSupportActionBar().setDisplayShowHomeEnabled(true);
|
||||
getSupportActionBar().setTitle("Modificar Producto");
|
||||
|
||||
user = (User) getIntent().getSerializableExtra("user");
|
||||
producto = (Producto) getIntent().getSerializableExtra("producto");
|
||||
databaseHelper = new DatabaseHelper(this);
|
||||
|
||||
nombreText = findViewById(R.id.nameText);
|
||||
hobbyText = findViewById(R.id.hobbyText);
|
||||
nombreText = findViewById(R.id.nombreText);
|
||||
precioText = findViewById(R.id.precioText);
|
||||
cantidadText = findViewById(R.id.cantidadText);
|
||||
|
||||
updateButton = findViewById(R.id.updateButton);
|
||||
deleteButton = findViewById(R.id.deleteButton);
|
||||
|
||||
nombreText.setText(user.getName());
|
||||
hobbyText.setText(user.getHobby());
|
||||
nombreText.setText(producto.getNombre());
|
||||
precioText.setText(String.valueOf(producto.getPrecio()));
|
||||
cantidadText.setText(String.valueOf(producto.getCantidad()));
|
||||
|
||||
updateButton.setOnClickListener(onUpdate());
|
||||
deleteButton.setOnClickListener(onDelete());
|
||||
@@ -52,7 +57,7 @@ public class UpdateDeleteActivity extends AppCompatActivity {
|
||||
.setPositiveButton("Si", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
databaseHelper.deleteUser(user.getId());
|
||||
databaseHelper.deleteProducto(producto.getId());
|
||||
Toast.makeText(
|
||||
UpdateDeleteActivity.this,
|
||||
"Usuario eliminado correctamente",
|
||||
@@ -72,8 +77,9 @@ public class UpdateDeleteActivity extends AppCompatActivity {
|
||||
return new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (user.getName().equals(nombreText.getText().toString()) &&
|
||||
user.getHobby().equals(hobbyText.getText().toString())
|
||||
if (producto.getNombre().equals(nombreText.getText().toString()) &&
|
||||
String.valueOf(producto.getPrecio()).equals(precioText.getText().toString()) &&
|
||||
String.valueOf(producto.getCantidad()).equals(cantidadText.getText().toString())
|
||||
) {
|
||||
Toast.makeText(
|
||||
UpdateDeleteActivity.this,
|
||||
@@ -83,21 +89,19 @@ public class UpdateDeleteActivity extends AppCompatActivity {
|
||||
return;
|
||||
}
|
||||
|
||||
databaseHelper.updateUser(
|
||||
user.getId(),
|
||||
databaseHelper.updateProducto(
|
||||
producto.getId(),
|
||||
nombreText.getText().toString(),
|
||||
hobbyText.getText().toString()
|
||||
Integer.valueOf(cantidadText.getText().toString()),
|
||||
Integer.valueOf(precioText.getText().toString())
|
||||
);
|
||||
Toast.makeText(
|
||||
UpdateDeleteActivity.this,
|
||||
"ACTUALIZACIÓN EXITOSA!",
|
||||
"Actualización realizada!",
|
||||
Toast.LENGTH_LONG
|
||||
).show();
|
||||
|
||||
Intent intent = new Intent(UpdateDeleteActivity.this, AddUserActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
package xyz.danielcortes.androidsqlite;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class User implements Serializable {
|
||||
private int id;
|
||||
private String name;
|
||||
private String hobby;
|
||||
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getHobby() {
|
||||
return hobby;
|
||||
}
|
||||
|
||||
public void setHobby(String hobby) {
|
||||
this.hobby = hobby;
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".AddUserActivity">
|
||||
tools:context=".AddProductoActivity">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/nombreText"
|
||||
@@ -15,25 +15,39 @@
|
||||
android:layout_marginEnd="16dp"
|
||||
android:ems="10"
|
||||
android:hint="Nombre"
|
||||
android:inputType="none"
|
||||
android:inputType="text"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/hobbyText"
|
||||
android:id="@+id/precioText"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:ems="10"
|
||||
android:hint="Hobby"
|
||||
android:inputType="none"
|
||||
android:hint="Precio"
|
||||
android:inputType="numberSigned|number"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/nombreText" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/cantidadText"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:ems="10"
|
||||
android:hint="Cantidad"
|
||||
android:inputType="numberSigned|number"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/precioText" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/grabarButton"
|
||||
style="@android:style/Widget.Material.Button.Colored"
|
||||
@@ -44,7 +58,8 @@
|
||||
android:layout_marginEnd="16dp"
|
||||
android:text="Grabar"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/hobbyText" />
|
||||
app:layout_constraintTop_toBottomOf="@+id/cantidadText" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -2,10 +2,9 @@
|
||||
<androidx.constraintlayout.widget.ConstraintLayout 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"
|
||||
android:id="@+id/linearLayout2"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".GetAllUsersActivity">
|
||||
tools:context=".GetAllProductosActivity">
|
||||
|
||||
<ListView
|
||||
android:id="@+id/listView"
|
||||
@@ -15,8 +14,9 @@
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
app:layout_constraintBottom_toTopOf="@+id/agregarButton"
|
||||
app:layout_constraintBottom_toTopOf="@+id/totalText"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
@@ -32,6 +32,18 @@
|
||||
android:text="Agregar"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="1.0"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/totalText"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
app:layout_constraintBottom_toTopOf="@+id/agregarButton"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -7,28 +7,44 @@
|
||||
tools:context=".UpdateDeleteActivity">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/nameText"
|
||||
android:id="@+id/nombreText"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:hint="Nombre"
|
||||
android:inputType="text"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/hobbyText"
|
||||
android:id="@+id/precioText"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:hint="Hobby"
|
||||
android:hint="Precio"
|
||||
android:inputType="numberSigned|number"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/nameText" />
|
||||
app:layout_constraintTop_toBottomOf="@+id/nombreText" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/cantidadText"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:hint="Cantidad"
|
||||
android:inputType="numberSigned"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/precioText" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/updateButton"
|
||||
@@ -39,18 +55,20 @@
|
||||
android:layout_marginEnd="16dp"
|
||||
android:text="Actualizar"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/hobbyText" />
|
||||
app:layout_constraintTop_toBottomOf="@+id/cantidadText" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/deleteButton"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginTop="12dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:text="Borrar"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/updateButton" />
|
||||
|
||||
|
||||
@@ -2,35 +2,56 @@
|
||||
<androidx.constraintlayout.widget.ConstraintLayout 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"
|
||||
android:id="@+id/linearLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/nameText"
|
||||
android:id="@+id/nombreText"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:text="TextView"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/hobbyText"
|
||||
android:id="@+id/precioText"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:text="TextView"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/nameText" />
|
||||
app:layout_constraintTop_toBottomOf="@+id/nombreText" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/cantidadText"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/precioText" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/totalText"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/cantidadText" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
<resources>
|
||||
<string name="app_name">AndroidSQLite</string>
|
||||
<string name="app_name">Lista de Compra</string>
|
||||
</resources>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Project-wide Gradle settings.
|
||||
# IDE (e.g. Android Studio) users:
|
||||
# IDE (e.g. Android Studio) productos:
|
||||
# Gradle settings configured through the IDE *will override*
|
||||
# any settings specified in this file.
|
||||
# For more details on how to configure your build environment visit
|
||||
|
||||
4
gradlew
vendored
4
gradlew
vendored
@@ -106,7 +106,7 @@ fi
|
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock
|
||||
if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:nombre=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin, switch paths to Windows format before running java
|
||||
@@ -123,7 +123,7 @@ if $cygwin ; then
|
||||
SEP="|"
|
||||
done
|
||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||
# Add a user-defined pattern to the cygpath arguments
|
||||
# Add a producto-defined pattern to the cygpath arguments
|
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user