06-20 22:53:42.240: E/AndroidRuntime(657): FATAL EXCEPTION: main
06-20 22:53:42.240: E/AndroidRuntime(657): java.lang.NullPointerException
06-20 22:53:42.240: E/AndroidRuntime(657): at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:355)
06-20 22:53:42.240: E/AndroidRuntime(657): at android.widget.ArrayAdapter.getView(ArrayAdapter.java:323)
06-20 22:53:42.240: E/AndroidRuntime(657): at android.widget.AbsListView.obtainView(AbsListView.java:1430)
06-20 22:53:42.240: E/AndroidRuntime(657): at android.widget.ListView.measureHeightOfChildren(ListView.java:1216)
06-20 22:53:42.240: E/AndroidRuntime(657): at android.widget.ListView.onMeasure(ListView.java:1127)
06-20 22:53:42.240: E/AndroidRuntime(657): at android.view.View.measure(View.java:8313)
06-20 22:53:42.240: E/AndroidRuntime(657): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138)
06-20 22:53:42.240: E/AndroidRuntime(657): at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1017)
06-20 22:53:42.240: E/AndroidRuntime(657): at android.widget.LinearLayout.measureVertical(LinearLayout.java:386)
06-20 22:53:42.240: E/AndroidRuntime(657): at android.widget.LinearLayout.onMeasure(LinearLayout.java:309)
06-20 22:53:42.240: E/AndroidRuntime(657): at android.view.View.measure(View.java:8313)
06-20 22:53:42.240: E/AndroidRuntime(657): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138)
06-20 22:53:42.240: E/AndroidRuntime(657): at android.widget.FrameLayout.onMeasure(FrameLayout.java:250)
06-20 22:53:42.240: E/AndroidRuntime(657): at android.view.View.measure(View.java:8313)
06-20 22:53:42.240: E/AndroidRuntime(657): at android.widget.LinearLayout.measureVertical(LinearLayout.java:531)
06-20 22:53:42.240: E/AndroidRuntime(657): at android.widget.LinearLayout.onMeasure(LinearLayout.java:309)
06-20 22:53:42.240: E/AndroidRuntime(657): at android.view.View.measure(View.java:8313)
06-20 22:53:42.240: E/AndroidRuntime(657): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138)
06-20 22:53:42.240: E/AndroidRuntime(657): at android.widget.FrameLayout.onMeasure(FrameLayout.java:250)
06-20 22:53:42.240: E/AndroidRuntime(657): at android.view.View.measure(View.java:8313)
06-20 22:53:42.240: E/AndroidRuntime(657): at android.view.ViewRoot.performTraversals(ViewRoot.java:839)
06-20 22:53:42.240: E/AndroidRuntime(657): at android.view.ViewRoot.handleMessage(ViewRoot.java:1859)
06-20 22:53:42.240: E/AndroidRuntime(657): at android.os.Handler.dispatchMessage(Handler.java:99)
06-20 22:53:42.240: E/AndroidRuntime(657): at android.os.Looper.loop(Looper.java:123)
06-20 22:53:42.240: E/AndroidRuntime(657): at android.app.ActivityThread.main(ActivityThread.java:3683)
06-20 22:53:42.240: E/AndroidRuntime(657): at java.lang.reflect.Method.invokeNative(Native Method)
06-20 22:53:42.240: E/AndroidRuntime(657): at java.lang.reflect.Method.invoke(Method.java:507)
06-20 22:53:42.240: E/AndroidRuntime(657): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
06-20 22:53:42.240: E/AndroidRuntime(657): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
06-20 22:53:42.240: E/AndroidRuntime(657): at dalvik.system.NativeStart.main(Native Method)
06-20 22:53:44.380: I/Process(657): Sending signal. PID: 657 SIG: 9
有人可以告诉我这个错误日志说的是什么吗?
public class Timetablledisplay extends Activity {
ListView lv;
TextView tv;
TextView td;
Gallery myHorizontalListView1;
Gallery myHorizontalListView2;
Gallery myHorizontalListView3;
Gallery myHorizontalListView4;
Gallery myHorizontalListView5;
Gallery myHorizontalListView6;
static int position;
int datepos=0;
Button back,front;
TextView e1,e2,e3,e4,e5,e6;
String p0[]={"Free","Free","Free","Free","Free","Free"};
String p01[]={"Free","Free","Free","Free","Free","Free"};
String p1[]=new String[40];
String p2[]=new String[40];
String p3[]=new String[40];
String p4[]=new String[40];
String p5[]=new String[40];
String p6[]=new String[40];
String sub[]=new String[40];
String sub1[]=new String[40];
String sub2[]=new String[40];
String sub3[]=new String[40];
String sub4[]=new String[40];
String sub5[]=new String[40];
String[] sw=new String[23];
String restoredText,restoredText1,restoredText2;
String x[]={"Attended","Bunked","Free Hour"};
String x1[]={"Attended","Bunked","Holiday"};
Calendar c = Calendar.getInstance();
Date newDate1;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.timetabledisplay);
try{
getSettings();
getTimeTablesetting();
Log.d("ERRRRRORRR",""+p1[0]);
lv=(ListView)findViewById(R.id.listView1);
tv=(TextView)findViewById(R.id.textdate);
td=(TextView)findViewById(R.id.textday);
c.add(Calendar.DATE, 0);
newDate1 = c.getTime();
td.setText(setdate(newDate1.getDay()));
try{
int i;
//get it from database
for(i=0;i<ProjectBunkitActivity.pos;i++){
p1[i]=sub[i];
p2[i]=sub1[i];
p3[i]=sub2[i];
p4[i]=sub3[i];
p5[i]=sub4[i];
p6[i]=sub5[i];
}
Log.d("ERRRRRORRR",""+p1[0]);
dateUpdate();
Log.d("DATEUPDATE", "HGJVVM");
front=(Button)findViewById(R.id.fwdarrow);
back=(Button)findViewById(R.id.bckarrow);
Log.d("DBBBBBBPOSITION5",""+position);
Calendar cal=Calendar.getInstance();
Date newd=cal.getTime();
Log.d("date",""+newd.getDay());
try{
if(setdate(newDate1.getDay())=="MON")
{
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
R.layout.listarray, android.R.id.text1, p1);
lv.setAdapter(adapter);
}
else if(setdate(newDate1.getDay())=="TUE"){
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
R.layout.listarray, android.R.id.text1, p2);
lv.setAdapter(adapter);
}
else if(setdate(newDate1.getDay())=="WED"){
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
R.layout.listarray, android.R.id.text1, p3);
lv.setAdapter(adapter);
}
else if(setdate(newDate1.getDay())=="THU"){
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
R.layout.listarray, android.R.id.text1, p4);
lv.setAdapter(adapter);
}
else if(setdate(newDate1.getDay())=="FRI"){
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
R.layout.listarray, android.R.id.text1, p5);
lv.setAdapter(adapter);
}
else if(setdate(newDate1.getDay())=="SAT"){
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
R.layout.listarray, android.R.id.text1, p6);
lv.setAdapter(adapter);
}
else
{
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
R.layout.listarray, android.R.id.text1, p1);
lv.setAdapter(adapter);
}
}catch (Exception e) {
// TODO: handle exception
}
lv.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, final int arg2,
long arg3) {
// TODO Auto-generated method stub
AlertDialog.Builder builder = new AlertDialog.Builder(Timetablledisplay.this);
builder.setTitle("Pick a choice");
builder.setSingleChoiceItems(x, -1, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
//Toast.makeText(getApplicationContext(), x[item], Toast.LENGTH_SHORT).show();
if(newDate1.getDay()==1){
changeLabel(arg2, item, p1, 1);
}
else if(newDate1.getDay()==2){
changeLabel(arg2, item, p2, 2);
}
else if(newDate1.getDay()==3){
changeLabel(arg2, item, p3, 3);
}
else if(newDate1.getDay()==4){
changeLabel(arg2, item, p4, 4);
}
else if(newDate1.getDay()==5){
changeLabel(arg2, item, p5, 5);
}
else if(newDate1.getDay()==6){
changeLabel(arg2, item, p6, 6);
}
else{
changeLabel(arg2, item, p0, 7);
}
updateview();
dialog.dismiss();
DBmanager(attendance(),newDate1);
//defaultview();
Log.d("aaaaaaaaaaaaaaaaaaaaa","bbbbbbbbbbbbbbbbbbbbbbbb");
}
});
AlertDialog alert = builder.create();
alert.show();
}
});
back.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
newDate1.setDate(newDate1.getDate()-1);
update(newDate1);
if(updateViewUsingDB()==null){
defaultview();
}
else
{
switch (newDate1.getDay())
{
case 0:
p0=updateViewUsingDB();
break;
case 1:
p1=updateViewUsingDB();
break;
case 2:
p2=updateViewUsingDB();
break;
case 3:
p3=updateViewUsingDB();
break;
case 4:
p4=updateViewUsingDB();
break;
case 5:
p5=updateViewUsingDB();
break;
case 6:
p6=updateViewUsingDB();
break;
default:
}
}
updateview();
DBmanager(attendance(),newDate1);
}
});
front.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
newDate1.setDate(newDate1.getDate()+1);
update(newDate1);
if(updateViewUsingDB()==null){
defaultview();
}
else
{
switch (newDate1.getDay())
{
case 0:
p0=updateViewUsingDB();
break;
case 1:
p1=updateViewUsingDB();
break;
case 2:
p2=updateViewUsingDB();
break;
case 3:
p3=updateViewUsingDB();
break;
case 4:
p4=updateViewUsingDB();
break;
case 5:
p5=updateViewUsingDB();
break;
case 6:
p6=updateViewUsingDB();
break;
default:
}
}
updateview();
DBmanager(attendance(),newDate1);
}
});
Log.d("DBBBBBBPOSITION2JGH",""+position);
DBmanager(attendance(),newDate1);
}catch (Exception e) {
// TODO: handle exception
}
}catch (Exception e) {
// TODO: handle exception
Log.d("ERRRRRORRR","DONE");
}
}
public void defaultview(){
try{
for(int i=0;i<ProjectBunkitActivity.pos;i++){
p1[i]=sub[i];
p2[i]=sub1[i];
p3[i]=sub2[i];
p4[i]=sub3[i];
p5[i]=sub4[i];
p6[i]=sub5[i];
}
}catch (Exception e) {
// TODO: handle exception
}
}
public String attendance(){
String attn=null;
try{
switch (newDate1.getDay())
{
case 0:
attn=stringConcat(p0);
break;
case 1:
attn=stringConcat(p1);
break;
case 2:
attn=stringConcat(p2);
break;
case 3:
attn=stringConcat(p3);
break;
case 4:
attn=stringConcat(p4);
break;
case 5:
attn=stringConcat(p5);
break;
case 6:
attn=stringConcat(p6);
break;
default:
attn=stringConcat(p0);
}
}catch (Exception e) {
// TODO: handle exception
}
return attn;
}
public void DBmanager(String attendance,Date theDate){
try{
Random rand=new Random();
int i=newDate1.getDate();
String s=setdate(newDate1.getDay());
String mnth=setmon(newDate1.getMonth());
long timevar=newDate1.getTime();
int k;
k=(100*newDate1.getDate())+newDate1.getMonth();
SQLiteDatabase db=openOrCreateDatabase("bunkDBNxTGeN", MODE_PRIVATE, null);
ContentValues cv= new ContentValues();
cv.put("curId", position);
cv.put("curPos",k);
cv.put("curDay",s);
cv.put("curDate",i);
cv.put("curMnth",mnth);
cv.put("curAttend",attendance);
cv.put("curTime", timevar);
position=rand.nextInt(10000-0)+0;
db.execSQL("CREATE TABLE IF NOT EXISTS theTable(curId INT(3),curPos INT(3),curTime INT(20),curDate INT(2),curDay VARCHAR,curMnth VARCHAR,curAttend VARCHAR);");
db.insert("theTable",null, cv);
Cursor c=db.rawQuery("SELECT * FROM theTable", null);
c.moveToLast();
Log.d("DB Message1", c.getString(c.getColumnIndex("curId")));
Log.d("DB Message1", c.getString(c.getColumnIndex("curPos")));
Log.d("DB Message2", c.getString(c.getColumnIndex("curDate")));
Log.d("DB Message3", c.getString(c.getColumnIndex("curDay")));
Log.d("DB Message4", c.getString(c.getColumnIndex("curMnth")));
Log.d("DB Message5", c.getString(c.getColumnIndex("curAttend")));
Log.d("DB Message6", c.getString(c.getColumnIndex("curTime")));
db.execSQL("CREATE TABLE temp AS SELECT * FROM theTable ORDER BY curTime");
db.execSQL("DROP TABLE theTable");
db.execSQL("ALTER TABLE temp RENAME TO theTable");
db.execSQL("DELETE FROM theTable WHERE curId NOT IN (SELECT curId FROM theTable GROUP BY curPos);");
c.close();
db.close();
}catch (Exception e) {
// TODO: handle exception
Log.d("DB Message Error",e.toString());
}
}
@SuppressWarnings("finally")
public String stringConcat(String [] arr){
String str = "";
try{
for (int i = 0;i<arr.length; i++) {
str = str+arr[i];
if(i<arr.length-1){
str = str+",";
}
}
}catch (Exception e) {
// TODO: handle exception
}
finally{
return str;
}
}
@SuppressWarnings("finally")
public String [] stringUncat(String str)
{
String[] arr=null;
try{
arr= str.split(",");
}catch (Exception e) {
// TODO: handle exception
}
finally{
return arr;
}
}
public String[] updateViewUsingDB(){
int curDate;
curDate=(100*newDate1.getDate())+newDate1.getMonth();
String s12=null;
String s123[];
int index,x;
SQLiteDatabase db=openOrCreateDatabase("bunkDBNxTGeN", MODE_PRIVATE, null);
try{
if (db == null) {
Log.d("Database", "Not Found!!!");
}
else {
Cursor c=db.rawQuery("SELECT * FROM theTable", null);
c.moveToFirst();
index=c.getColumnIndex("curPos");
x=Integer.parseInt(c.getString(index));
while(index!=-1)
{
if(x==curDate)
{
s123=stringUncat(c.getString(c.getColumnIndex("curAttend")));
db.close();
return s123;
}
else{
c.moveToNext();
index=c.getColumnIndex("curPos");
x=Integer.parseInt(c.getString(index));
}
}
Log.d("DATABASE","UREAKAAAAAAAAAAAAAAAA"+s12);
}
db.close();
}catch (Exception e) {
// TODO: handle exception
Log.d("DATABASE INFO",e.toString());
db.close();
}
db.close();
return null;
}
public void updateview()
{
Log.d("DATEUPDATAVSCXZVAQAndlekdn", p1[0]);
try{
Log.d("DATEUPDAfSFSffdsFSDFAFkSDACDCSDndlekdn", p1[0]);
if(setdate(newDate1.getDay())=="MON")
{
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
R.layout.listarray, android.R.id.text1, p1);
lv.setAdapter(adapter);
}
else if(setdate(newDate1.getDay())=="TUE"){
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
R.layout.listarray, android.R.id.text1, p2);
lv.setAdapter(adapter);
Log.d("DATEUPDATFwegfegewgRGSggekndlekdn", p1[0]);
}
else if(setdate(newDate1.getDay())=="WED"){
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
R.layout.listarray, android.R.id.text1, p3);
lv.setAdapter(adapter);
}
else if(setdate(newDate1.getDay())=="THU"){
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
R.layout.listarray, android.R.id.text1, p4);
lv.setAdapter(adapter);
}
else if(setdate(newDate1.getDay())=="FRI"){
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
R.layout.listarray, android.R.id.text1, p5);
lv.setAdapter(adapter);
}
else if(setdate(newDate1.getDay())=="SAT"){
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
R.layout.listarray, android.R.id.text1, p6);
lv.setAdapter(adapter);
}
else
{
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
R.layout.listarray, android.R.id.text1, p0);
lv.setAdapter(adapter);
}
Log.d("DATEUPDAEFWEGFRHTkndlekdn", p1[0]);
}
catch (Exception e) {
// TODO: handle exception
}
}
public void dateUpdate(){
try{
int m;
Calendar c = Calendar.getInstance();
Date newDate = c.getTime();
Log.d("DateXXX","heyyy");
String s=setdate(newDate.getDay());
String x=setmon(newDate.getMonth());
Log.d("DATEEEEE",""+newDate.getDate());
m=newDate.getDate();
td.setText(s);
tv.setText(x+","+m);
updateview();
}
catch (Exception e) {
Log.d("HEY THEREs An ERROR",e.toString());
}
}
public void update(Date p)
{
try{
int m;
String s=setdate(p.getDay());
String x=setmon(p.getMonth());
m=p.getDate();
td.setText(s);
tv.setText(x+","+m);
}
catch (Exception e) {
Log.d("HEY THERE An ERROR",e.toString());
}
}
private String setmon(int month) {
// TODO Auto-generated method stub
String d=null;
try{
switch (month){
case 0:d="JAN";
break;
case 1:d="FEB";
break;
case 2:d="MAR";
break;
case 3:d="APL";
break;
case 4:d="MAY";
break;
case 5:d="JUN";
break;
case 6:d="JULY";
break;
case 7:d="AUG";
break;
case 8:d="SEP";
break;
case 9:d="OCT";
break;
case 10:d="NOV";
break;
case 11:d="DEC";
break;
default:d="JAN";
}
}catch (Exception e) {
// TODO: handle exception
}
return d;
}
private String setdate(int day) {
// TODO Auto-generated method stub
String d=null;
try{
switch (day)
{
case 0:d="SUN";
break;
case 1:d="MON";
break;
case 2:d="TUE";
break;
case 3:d="WED";
break;
case 4:d="THU";
break;
case 5:d="FRI";
break;
case 6:d="SAT";
break;
default:d="MON1";
}
}catch (Exception e) {
// TODO: handle exception
}
return d;
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
try{
MenuInflater inflater = getMenuInflater(); //
inflater.inflate(R.menu.menu, menu); //
}catch (Exception e) {
// TODO: handle exception
}
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// TODO Auto-generated method stub
try{
switch (item.getItemId()) {
case R.id.itemPrefs:
startActivity(new Intent(this, ProjectBunkitActivity.class));
break;
case R.id.itemPrefs1:
startActivity(new Intent(this,Display.class));
}
}catch (Exception e) {
// TODO: handle exception
}
return super.onOptionsItemSelected(item);
}
public String[] changeLabel(int i,int j,String[] p,int l) {
// TODO Auto-generated method stub
//p6[arg2]=x[item];
try{
String storage[][]={
sub,
sub1,
sub2,
sub3,
sub4,
sub5,p01};
//Toast toast = Toast.makeText(Timetablledisplay.this,storage[l-1][i],Toast.LENGTH_SHORT);
//toast.show();
switch (j) {
case 0:
p[i]=storage[l-1][i];
break;
case 1:p[i]="BNK";
break;
case 2:p[i]="FREE";
break;
default:
break;
}
DBmanager(attendance(),newDate1);
}catch (Exception e) {
// TODO: handle exception
}
return p;
}
@Override
protected void onResume() {
// TODO Auto-generated method stub
super.onResume();
try{
Calendar ca=Calendar.getInstance();
ca.add(Calendar.DATE, 0);
Date dres=ca.getTime();
newDate1=dres;
Log.d("DATEUPDATE", "DONE");
dateUpdate();
}
catch (Exception e) {
// TODO: handle exception
Log.d("DATEUPDATE", e.toString());
}
}
@Override
protected void onPause() {
// TODO Auto-generated method stub
try{
super.onPause();
Log.d("DATqewDATE", "jhwedhjkebjd");
}catch (Exception e) {
// TODO: handle exception
}
// SharedPreferences.Editor editor = getPreferences(0).edit();
// editor.putInt("position",position);
}
@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onRestoreInstanceState(savedInstanceState);
Log.d("DATEUPDATE", "HGJVVM");
try{
p1=savedInstanceState.getStringArray("mond");
p2=savedInstanceState.getStringArray("tued");
p3=savedInstanceState.getStringArray("wedd");
p4=savedInstanceState.getStringArray("thud");
p5=savedInstanceState.getStringArray("frid");
p6=savedInstanceState.getStringArray("satd");
Calendar ca=Calendar.getInstance();
ca.add(Calendar.DATE, 0);
Date dres=ca.getTime();
newDate1=dres;
Log.d("DATEUPDATE1212", "DONE");
dateUpdate();
}catch (Exception e) {
// TODO: handle exception
}
}
@Override
protected void onSaveInstanceState(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onSaveInstanceState(savedInstanceState);
try{
savedInstanceState.putStringArray("mond", p1);
savedInstanceState.putStringArray("tued", p2);
savedInstanceState.putStringArray("wedd", p3);
savedInstanceState.putStringArray("thud", p4);
savedInstanceState.putStringArray("frid", p5);
savedInstanceState.putStringArray("satd", p6);
}catch (Exception e) {
// TODO: handle exception
}
}
@Override
public void onBackPressed() {
// TODO Auto-generated method stub
}
public void getSettings(){
try{
SharedPreferences prefs = getSharedPreferences("myfile",0);
restoredText = prefs.getString("text", null);
restoredText1 = prefs.getString("cpd", null);
restoredText2= prefs.getString("nos", null);
int pos1=prefs.getInt("pos",1);
int l=0;
if (restoredText != null) {
Log.d("HHHHH", "Here"+pos1);
try{
for(int j=0;j<=pos1-1;j++)
{
sw[l]=prefs.getString("sub"+l,null);
Log.d("DATA FROM PREFS",sw[l]);
l++;
}
}
catch(Exception e)
{
Toast toast = Toast.makeText(Timetablledisplay.this,e.toString()+"5",Toast.LENGTH_SHORT);
toast.show();
}
getTimeTablesetting();
}
}catch (Exception e) {
// TODO: handle exception
}
}
public void getTimeTablesetting(){
SharedPreferences prefs = getSharedPreferences("myTime",0);
try{
if(ProjectBunkitActivity.pos==prefs.getInt("pos",0)){
if(prefs.getString("sub"+2, null) != null)
{
for(int i=0;i<prefs.getInt("pos",0);i++)
{
sub[i] = prefs.getString("sub"+i, null);
sub1[i] = prefs.getString("sub1"+i, null);
sub2[i] = prefs.getString("sub2"+i, null);
sub3[i] = prefs.getString("sub3"+i, null);
sub4[i] = prefs.getString("sub4"+i, null);
sub5[i] = prefs.getString("sub5"+i, null);
Log.d("DATA FROM PREFS FOR TIME TABLE",sub[i]+i);
}
}
}
}catch (Exception e) {
// TODO: handle exception
Log.d("DATA FROM PREFS FOR TIME TABLE","ERROR");
}
}
}
此代码从首选项中获取一些值并将其转换为列表视图,并在按下后退或前进按钮时更新日期。它还将数据写入db
答案 0 :(得分:3)
NullPointerException
可能只有两种可能的原因:
您为适配器应放置数据的id
提供了错误的TextView
。
例如,如果你这个构造函数:
ArrayAdapter<...>(Context, R.layout.layout_file, R.id.textview, List data);
然后R.id.textview
不是id
中View
的{{1}}。
R.layout.layout_file
/ null
中的List
值表示传递给适配器的数据 array
布局文件中是否有TextView
id
@android:id/text1
?如果没有,那就是问题的根源。
修改强>
查看代码,问题可能是那些R.layout.listarray
,p1
数组。您声明它们的大小为p2
,但是您是否填写了它们中的所有位置?你有40
个值放在那些数组中吗?如果没有,那么在某些时候你只有40
个值而且适配器不喜欢它。
将其中的值打印到null
,看看这些数组中是否有logcat
个值。如果你这样做,那很可能是你的问题。