Niente, non capisco, dal log ho sempre lo stesso erore alla linea 167, anche con il tuo suggerimento,
questo e il log:[02-14 20:12:52.918: E/dalvikvm(7779): Unable to open stack trace file '/data/anr/traces.txt': Is a directory
02-14 20:12:53.098: I/dalvikvm(7779): threadid=3: reacting to signal 3
02-14 20:12:53.128: I/dalvikvm(7779): Wrote stack traces to '/data/anr/traces.txt'
02-14 20:12:53.578: D/AndroidRuntime(7779): Shutting down VM
02-14 20:12:53.578: W/dalvikvm(7779): threadid=1: thread exiting with uncaught exception (group=0x409c01f8)
02-14 20:12:53.598: I/dalvikvm(7779): threadid=3: reacting to signal 3
02-14 20:12:53.648: E/AndroidRuntime(7779): FATAL EXCEPTION: main
02-14 20:12:53.648: E/AndroidRuntime(7779): java.lang.RuntimeException: Unable to resume activity {turni.db.tab/com.turniDB.Main}: java.lang.RuntimeException: Unable to resume activity {turni.db.tab/com.turniDB.Gennaio}: android.database.CursorIndexOutOfBoundsException: Index 0 requested, with a size of 0
02-14 20:12:53.648: E/AndroidRuntime(7779): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2444)
02-14 20:12:53.648: E/AndroidRuntime(7779): at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2472)
02-14 20:12:53.648: E/AndroidRuntime(7779): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1986)
02-14 20:12:53.648: E/AndroidRuntime(7779): at android.app.ActivityThread.access$600(ActivityThread.java:123)
02-14 20:12:53.648: E/AndroidRuntime(7779): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
02-14 20:12:53.648: E/AndroidRuntime(7779): at android.os.Handler.dispatchMessage(Handler.java:99)
02-14 20:12:53.648: E/AndroidRuntime(7779): at android.os.Looper.loop(Looper.java:137)
02-14 20:12:53.648: E/AndroidRuntime(7779): at android.app.ActivityThread.main(ActivityThread.java:4424)
02-14 20:12:53.648: E/AndroidRuntime(7779): at java.lang.reflect.Method.invokeNative(Native Method)
02-14 20:12:53.648: E/AndroidRuntime(7779): at java.lang.reflect.Method.invoke(Method.java:511)
02-14 20:12:53.648: E/AndroidRuntime(7779): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
02-14 20:12:53.648: E/AndroidRuntime(7779): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
02-14 20:12:53.648: E/AndroidRuntime(7779): at dalvik.system.NativeStart.main(Native Method)
02-14 20:12:53.648: E/AndroidRuntime(7779): Caused by: java.lang.RuntimeException: Unable to resume activity {turni.db.tab/com.turniDB.Gennaio}: android.database.CursorIndexOutOfBoundsException: Index 0 requested, with a size of 0
02-14 20:12:53.648: E/AndroidRuntime(7779): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2444)
02-14 20:12:53.648: E/AndroidRuntime(7779): at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:178)
02-14 20:12:53.648: E/AndroidRuntime(7779): at android.app.LocalActivityManager.dispatchResume(LocalActivityManager.java:523)
02-14 20:12:53.648: E/AndroidRuntime(7779): at android.app.ActivityGroup.onResume(ActivityGroup.java:61)
02-14 20:12:53.648: E/AndroidRuntime(7779): at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1154)
02-14 20:12:53.648: E/AndroidRuntime(7779): at android.app.Activity.performResume(Activity.java:4539)
02-14 20:12:53.648: E/AndroidRuntime(7779): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2434)
02-14 20:12:53.648: E/AndroidRuntime(7779): ... 12 more
02-14 20:12:53.648: E/AndroidRuntime(7779): Caused by: android.database.CursorIndexOutOfBoundsException: Index 0 requested, with a size of 0
02-14 20:12:53.648: E/AndroidRuntime(7779): at android.database.AbstractCursor.checkPosition(AbstractCursor.java:400)
02-14 20:12:53.648: E/AndroidRuntime(7779): at android.database.AbstractWindowedCursor.checkPosition(AbstractWindowedCursor.java:136)
02-14 20:12:53.648: E/AndroidRuntime(7779): at android.database.AbstractWindowedCursor.getInt(AbstractWindowedCursor.java:68)
02-14 20:12:53.648: E/AndroidRuntime(7779): at com.turniDB.Gennaio.displayTurni(Gennaio.java:167)
02-14 20:12:53.648: E/AndroidRuntime(7779): at com.turniDB.Gennaio.onResume(Gennaio.java:129)
02-14 20:12:53.648: E/AndroidRuntime(7779): at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1154)
02-14 20:12:53.648: E/AndroidRuntime(7779): at android.app.Activity.performResume(Activity.java:4539)
02-14 20:12:53.648: E/AndroidRuntime(7779): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2434)
02-14 20:12:53.648: E/AndroidRuntime(7779): ... 18 more
02-14 20:12:53.679: I/dalvikvm(7779): Wrote stack traces to '/data/anr/traces.txt'
02-14 20:12:54.142: I/dalvikvm(7779): threadid=3: reacting to signal 3
02-14 20:12:54.188: I/dalvikvm(7779): Wrote stack traces to '/data/anr/traces.txt'
02-14 20:12:54.288: I/dalvikvm(7779): threadid=3: reacting to signal 3
02-14 20:12:54.328: I/dalvikvm(7779): Wrote stack traces to '/data/anr/traces.txt'
]
e questa e la classe modificata come da te suggerito:
dataBase = mHelper.getWritableDatabase();
Cursor cCursor = dataBase.rawQuery("SELECT SUM(ORE) FROM " + DbHelper.TURNI_TABLE+"", null);
turno_totoRe.clear();
if (cCursor.moveToFirst()) {
do {
turno_totoRe.add(mCursor.getInt(0)+"");
} while (mCursor.moveToNext());
}
DisplayAdapter disadpt = new DisplayAdapter(Gennaio.this,turno_id, turno_mEse, turno_gIorno, turno_tUrno, turno_oRe, turno_totoRe );
userList.setAdapter(disadpt);
mCursor.close();
}
}}
Ho rincontrollato il display adpter ma non ho individuato errori, non so proprio dove cercare...
e questo è l'adapter se puo esserti utile come riferimento
package com.turniDB;
import java.util.ArrayList;
import turni.db.tab.R;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
public class DisplayAdapter extends BaseAdapter {
private Context mContext;
private ArrayList<String> id;
private ArrayList<String> mese;
private ArrayList<String> giorno;
private ArrayList<String> turno;
private ArrayList<String> ore;
private ArrayList<String> totore;
public DisplayAdapter(Context c, ArrayList<String> id,ArrayList<String> mese, ArrayList<String> giorno, ArrayList<String> turno, ArrayList<String> ore,ArrayList<String> totore) {
this.mContext = c;
this.id = id;
this.mese = mese;
this.giorno = giorno;
this.turno = turno;
this.ore = ore;
this.ore = totore;
}
public DisplayAdapter(Gennaio c,
ArrayList<String> turno_id,
ArrayList<String> turno_mEse,
ArrayList<String> turno_gIorno,
ArrayList<String> turno_tUrno,
ArrayList<String> turno_oRe,
ArrayList<String> turno_totoRe) {
// TODO Auto-generated constructor stub
}
public int getCount() {
// TODO Auto-generated method stub
return id.size();
}
public Object getItem(int position) {
// TODO Auto-generated method stub
return null;
}
public long getItemId(int position) {
// TODO Auto-generated method stub
return 0;
}
public View getView(int pos, View child, ViewGroup parent) {
Holder mHolder;
LayoutInflater layoutInflater;
if (child == null) {
layoutInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
child = layoutInflater.inflate(R.layout.main2, null);
mHolder = new Holder();
mHolder.txt_id = (TextView) child.findViewById(R.id.txt_id);
mHolder.txt_mEse = (TextView) child.findViewById(R.id.txt_mEse);
mHolder.txt_gIorno = (TextView) child.findViewById(R.id.txt_gIorno);
mHolder.txt_tUrno = (TextView) child.findViewById(R.id.txt_tUrno);
mHolder.txt_oRe = (TextView) child.findViewById(R.id.txt_oRe);
mHolder.txt_totoRe = (TextView) child.findViewById(R.id.texttotore);
child.setTag(mHolder);
} else {
mHolder = (Holder) child.getTag();
}
mHolder.txt_id.setText(id.get(pos));
mHolder.txt_mEse.setText(mese.get(pos));
mHolder.txt_gIorno.setText(giorno.get(pos));
mHolder.txt_tUrno.setText(turno.get(pos));
mHolder.txt_oRe.setText(ore.get(pos));
mHolder.txt_totoRe.setText(totore.get(pos));
return child;
}
public class Holder {
TextView txt_id;
TextView txt_mEse;
TextView txt_gIorno;
TextView txt_tUrno;
TextView txt_oRe;
TextView txt_totoRe;
}
}
Abbi pazienza ma sono due mesi che sono dietro ad apprendere e fermarmi adesso mi gira veramente l'anima. Grazie ancora.