After a long time trying to solve the problem I'm not left other than resorting to this means where I hope someone can help me with this problem. what happens is that I try to send information from a row of a ListView to a new activity where there are TextViews where I can modify the information that remains there, but I can not get the info to pass from the Activity list to the Activity Modify. when I touch a row the screen goes blank and returns to the Main Activity
LISTING
package com.example.adminclases.appsensor;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import java.util.ArrayList;
public class Listado extends AppCompatActivity {
ListView listView;
ArrayList<String> listado;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_listado);
listView = (ListView) findViewById(R.id.listaView);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
int id = Integer.parseInt(listado.get(i).split(" ")[0]);
String nombre=listado.get(i).split(" ")[1];
String usuario=listado.get(i).split(" ")[2];
String password=listado.get(i).split(" ")[3];
String correo=listado.get(i).split(" ")[4];
Intent intent=new Intent(Listado.this,Modificar.class);
intent.putExtra("ID",id);
intent.putExtra("NOMBRE",nombre);
intent.putExtra("USUARIO",usuario);
intent.putExtra("PASSWORD",password);
intent.putExtra("CORREO",correo);
startActivity(intent);
}
});
}
@Override
protected void onPostResume () {
super.onPostResume();
cargarlistado();
}
private void cargarlistado() {
listado = ListaPersonas();
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, listado);
listView.setAdapter(adapter);
}
private ArrayList<String> ListaPersonas() {
ArrayList<String> datos = new ArrayList<String>();
BaseHelper helper = new BaseHelper(this, "DEMO", null, 1);
SQLiteDatabase db = helper.getWritableDatabase();
String sql = "Select * from PERSONAS";
Cursor c = db.rawQuery(sql, null);
if (c.moveToFirst()) {
do {
String linea = " " + c.getInt(0) + " " + c.getString(1) + " " + c.getString(2) + " " + c.getString(3) + " " + c.getString(4);
datos.add(linea);
} while (c.moveToNext());
}
db.close();
return datos;
}
}
MODIFY
package com.example.adminclases.appsensor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
public class Modificar extends AppCompatActivity {
EditText ed_nombre,ed_usuario, ed_password, ed_correo;
Button btn_modificar,btn_eliminar;
int id_recibe;
String nombre_recibe,usuario_recibe, password_recibe, correo_recibe;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_modificar);
ed_nombre=(EditText) findViewById(R.id.ed_nombre);
ed_usuario=(EditText) findViewById(R.id.ed_usuario);
ed_password=(EditText) findViewById(R.id.ed_password);
ed_correo=(EditText) findViewById(R.id.ed_correo);
btn_modificar=(Button) findViewById(R.id.btn_modificar);
btn_eliminar=(Button) findViewById(R.id.btn_eliminar);
Bundle b=getIntent().getExtras();
if(b!=null)
{
id_recibe=b.getInt("ID");
nombre_recibe=b.getString("NOMBRE");
usuario_recibe=b.getString("USUARIO");
password_recibe=b.getString("PASSWORD");
correo_recibe=b.getString("CORREO");
}
ed_nombre.setText(nombre_recibe);
ed_usuario.setText(usuario_recibe);
ed_password.setText(password_recibe);
ed_correo.setText(correo_recibe);
btn_modificar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
modificar(id_recibe,ed_nombre.getText().toString(),ed_usuario.getText().toString(),ed_password.getText().toString(),ed_correo.getText().toString());
onBackPressed();
}
});
btn_eliminar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
eliminar(id_recibe);
onBackPressed();
}
});
}
private void modificar(int id, String nombre, String usuario, String password, String correo)
{
BaseHelper helper=new BaseHelper(this,"DEMO",null,1);
SQLiteDatabase db=helper.getWritableDatabase();
String sql="UPDATE PERSONAS SET NOMBRE='"+nombre+"', USUARIO='"+usuario+"', PASSWORD='"+password+"', CORREO='"+correo+"' WHERE ID="+id;
db.execSQL(sql);
}
private void eliminar(int id)
{
BaseHelper helper=new BaseHelper(this,"DEMO",null,1);
SQLiteDatabase db=helper.getWritableDatabase();
String sql="DELETE FROM PERSONAS WHERE ID="+id;
db.execSQL(sql);
}
}
ACTIVITY_LISTADO.XML
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
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:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.example.adminclases.appsensor.Listado"
android:weightSum="1">
<ListView
android:id="@+id/listaView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
ACTIVITY_MODIFY.XML
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
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:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.example.adminclases.appsensor.Modificar"
android:weightSum="1">
<TextView
android:id="@+id/Nombre"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Nombre"
android:textSize="24sp"
android:gravity="center"/>
<EditText
android:id="@+id/ed_nombre"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:background="@drawable/redondeoedittext"
android:inputType="textPersonName"
android:layout_weight="0.10" />
<TextView
android:id="@+id/Usuario"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:text="Usuario"
android:textSize="24sp"
android:gravity="center"/>
<EditText
android:id="@+id/ed_usuario"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:background="@drawable/redondeoedittext"
android:inputType="textPersonName"
android:layout_weight="0.10" />
<TextView
android:id="@+id/Password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:text="Password"
android:textSize="24sp"
android:gravity="center"/>
<EditText
android:id="@+id/ed_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:background="@drawable/redondeoedittext"
android:inputType="textPersonName"
android:layout_weight="0.10" />
<TextView
android:id="@+id/Correo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Correo"
android:textSize="24sp"
android:gravity="center"/>
<EditText
android:id="@+id/ed_correo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:background="@drawable/redondeoedittext"
android:inputType="textPersonName"
android:layout_weight="0.10" />
<Button
android:id="@+id/btn_modificar"
android:layout_width="100dp"
android:layout_height="50dp"
android:layout_marginLeft="150dp"
android:layout_marginTop="40dp"
android:background="#649dd9"
android:hint="Modificar" />
<Button
android:id="@+id/btn_eliminar"
android:layout_width="100dp"
android:layout_height="50dp"
android:layout_marginLeft="150dp"
android:layout_marginTop="40dp"
android:background="#649dd9"
android:hint="Eliminar" />
</LinearLayout>
ANDROID MANIFEST
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.adminclases.appsensor">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".ActivityIngreso" />
<activity android:name=".Listado" />
<activity android:name=".Modificar" />
</application>
LOGCAT
12-05 20:05:23.457 31835-31835/? I/art: Late-enabling -Xcheck:jni
12-05 20:05:23.569 31835-31835/com.example.adminclases.appsensor W/art:
Before Android 4.1, method android.graphics.PorterDuffColorFilter
android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter
(android.
graphics.PorterDuffColorFilter, android.content.res.ColorStateList,
android.graphics.PorterDuff$Mode)
would have incorrectly overridden the package-
private method in android.graphics.drawable.Drawable
12-05 20:05:23.734 31835-31865/com.example.adminclases.appsensor
D/OpenGLRenderer: Render dirty regions requested: true
12-05 20:05:23.740 31835-31835/com.example.adminclases.appsensor D/Atlas:
Validating map...
12-05 20:05:23.804 31835-31865/com.example.adminclases.appsensor I/Adreno-
EGL: <qeglDrvAPI_eglInitialize:379>: EGL 1.4 QUALCOMM build:
AU_LINUX_ANDROID_LA.BR.1.1.3.C4.05.00.02.094.015_msm8916_64_refs/tags/
AU_LINUX_
ANDROID_LA.BR.1.1.3.C4.05.00.02.094.015__release_AU (I68fa98814b)
OpenGL ES Shader Compiler Version: E031.25.03.02
Build Date: 07/16/15 Thu
Local Branch:
Remote Branch: refs/tags/AU_LINUX_ANDROID_LA.BR.1.1.3.C4.05.00.02.094.015
Local Patches: NONE
Reconstruct Branch: NOTHING
12-05 20:05:23.804 31835-31865/com.example.adminclases.appsensor
I/OpenGLRenderer: Initialized EGL, version 1.4
12-05 20:05:23.817 31835-31865/com.example.adminclases.appsensor
D/OpenGLRenderer: Enabling debug mode 0
12-05 20:05:23.950 31835-31835/com.example.adminclases.appsensor I/Timeline:
Timeline: Activity_idle id: android.os.BinderProxy@3338690f time:843740706