آموزش های این وب سایت به صورت رایگان در دسترس است. اطلاعات بیشتر
بروز خطا
   [message]
اشتراک در سوال
رای ها
[dataList]

مشکل در G.notes

iSheykhi  12 سال پیش  12 سال پیش
0 0

با سلام

سوال قبلی رو که کسی جواب نداد

مقادیر رو چک کردم

هرچیزی هست از G.notes هست

مقادیر تا پیش از رفتن به G.notes هیچ مشکلی ندارن اما بعد از انتقالشون برای نمایش فقط آخرین آیتم به صورت مکرر نمایش داده می شه

    public String              strTableNameSA;
public static ArrayAdapter adapter;
public StructNote note = new StructNote();
public StructList SList = new StructList();
public Cursor cursor;




private void cursorRunner(String strCommand) {
//
SList.clearMe();
cursor = G.db.rawQuery(strCommand, null);
while (cursor.moveToNext()) {
SList.IDList.add(cursor.getInt(cursor.getColumnIndex("id")));
SList.TitleList.add(cursor.getString(cursor.getColumnIndex("fldTitle")));
SList.DescList.add(cursor.getString(cursor.getColumnIndex("fldContent")));
SList.FavoriteList.add(Boolean.parseBoolean(cursor.getString(cursor.getColumnIndex("fldFavorite"))));
SList.SortList.add(cursor.getInt(cursor.getColumnIndex("fldSort")));
}
Log.i("tst", "SList.TitleList Is: " + SList.TitleList.toString());
Log.i("tst", "SList.TitleList.size Is: " + SList.TitleList.size());
for (int i = 0; i < SList.TitleList.size(); i++) {
Log.i("tst", "SList.TitleList " + i + " Is: " + SList.TitleList.get(i).toString());
}
cursor.close();
}


private void nodeSetter() {
G.notes.clear();
for (int i = 0; i < SList.TitleList.size(); i++) {
note.title = SList.TitleList.get(i);
note.detail = SList.DescList.get(i);
note.Favorite = SList.FavoriteList.get(i);
note.Sort = SList.SortList.get(i);
note.intID = SList.IDList.get(i);
note.nameOfTable = strTableNameSA;
G.notes.add(i, note);
Log.i("tst", "G.notes.Size Is: " + G.notes.size());
Log.i("tst", "note.title Is: " + note.title);
Log.i("tst", "note.detail Is: " + note.detail);
Log.i("tst", "note.Favorite Is: " + note.Favorite);
Log.i("tst", "note.Sort Is: " + note.Sort);
Log.i("tst", "note.intID Is: " + note.intID);
}
}


// Class StructList


import java.util.ArrayList;


public class StructList {

public ArrayList<String> TitleList = new ArrayList<String>();
public ArrayList<String> DescList = new ArrayList<String>();
public ArrayList<String> TableNameList = new ArrayList<String>();
public ArrayList<Integer> SortList = new ArrayList<Integer>();
public ArrayList<Integer> IDList = new ArrayList<Integer>();
public ArrayList<Boolean> FavoriteList = new ArrayList<Boolean>();


public void clearMe() {
TitleList.clear();
DescList.clear();
TableNameList.clear();
SortList.clear();
IDList.clear();
FavoriteList.clear();
}

}


// Class StructNote

public class StructNote {

public String nameOfTable;
public Integer Sort;
public Integer intID;
public Boolean Favorite;
public String title;
public String detail;
}
// قبل از ذخیره تغییرات

for (int i = 0; i < G.notes.size(); i++) {
Log.i("tst", "G.notes.title Is: " + G.notes.get(i).title);
}
// ذخیره تغییرات
adapter.notifyDataSetChanged();

نتیجه لوگ کت:

 04-24 19:39:50.398: I/tst(309): SList.TileList  Is: [نام, نام خانوادگی, شماره ملی, شماره تماس, کد پستی, ایمیل, نام پدر, شماره شناسنامه, تاریخ تولد]
04-24 19:39:50.398: I/tst(309): SList.TitleList.size Is: 9
04-24 19:39:50.408: I/tst(309): SList.TitleList 0 Is: نام
04-24 19:39:50.408: I/tst(309): SList.TitleList 1 Is: نام خانوادگی
04-24 19:39:50.408: I/tst(309): SList.TitleList 2 Is: شماره ملی
04-24 19:39:50.408: I/tst(309): SList.TitleList 3 Is: شماره تماس
04-24 19:39:50.408: I/tst(309): SList.TitleList 4 Is: کد پستی
04-24 19:39:50.408: I/tst(309): SList.TitleList 5 Is: ایمیل
04-24 19:39:50.408: I/tst(309): SList.TitleList 6 Is: نام پدر
04-24 19:39:50.408: I/tst(309): SList.TitleList 7 Is: شماره شناسنامه
04-24 19:39:50.408: I/tst(309): SList.TitleList 8 Is: تاریخ تولد
04-24 19:39:50.408: I/tst(309): G.notes.Size Is: 1
04-24 19:39:50.408: I/tst(309): note.title Is: نام
04-24 19:39:50.408: I/tst(309): note.detail Is: Amin
04-24 19:39:50.408: I/tst(309): note.Favorite Is: true
04-24 19:39:50.418: I/tst(309): note.Sort Is: 3
04-24 19:39:50.418: I/tst(309): note.intID Is: 4
04-24 19:39:50.418: I/tst(309): G.notes.Size Is: 2
04-24 19:39:50.418: I/tst(309): note.title Is: نام خانوادگی
04-24 19:39:50.418: I/tst(309): note.detail Is: Sheykhi
04-24 19:39:50.418: I/tst(309): note.Favorite Is: true
04-24 19:39:50.418: I/tst(309): note.Sort Is: 3
04-24 19:39:50.418: I/tst(309): note.intID Is: 5
04-24 19:39:50.418: I/tst(309): G.notes.Size Is: 3
04-24 19:39:50.428: I/tst(309): note.title Is: شماره ملی
04-24 19:39:50.428: I/tst(309): note.detail Is:
04-24 19:39:50.428: I/tst(309): note.Favorite Is: true
04-24 19:39:50.428: I/tst(309): note.Sort Is: 3
04-24 19:39:50.428: I/tst(309): note.intID Is: 7
04-24 19:39:50.428: I/tst(309): G.notes.Size Is: 4
04-24 19:39:50.428: I/tst(309): note.title Is: شماره تماس
04-24 19:39:50.428: I/tst(309): note.detail Is:
04-24 19:39:50.428: I/tst(309): note.Favorite Is: true
04-24 19:39:50.438: I/tst(309): note.Sort Is: 5
04-24 19:39:50.438: I/tst(309): note.intID Is: 1
04-24 19:39:50.438: I/tst(309): G.notes.Size Is: 5
04-24 19:39:50.438: I/tst(309): note.title Is: کد پستی
04-24 19:39:50.438: I/tst(309): note.detail Is:
04-24 19:39:50.438: I/tst(309): note.Favorite Is: true
04-24 19:39:50.448: I/tst(309): note.Sort Is: 5
04-24 19:39:50.448: I/tst(309): note.intID Is: 2
04-24 19:39:50.448: I/tst(309): G.notes.Size Is: 6
04-24 19:39:50.448: I/tst(309): note.title Is: ایمیل
04-24 19:39:50.448: I/tst(309): note.detail Is:
04-24 19:39:50.448: I/tst(309): note.Favorite Is: true
04-24 19:39:50.448: I/tst(309): note.Sort Is: 5
04-24 19:39:50.448: I/tst(309): note.intID Is: 3
04-24 19:39:50.448: I/tst(309): G.notes.Size Is: 7
04-24 19:39:50.448: I/tst(309): note.title Is: نام پدر
04-24 19:39:50.448: I/tst(309): note.detail Is:
04-24 19:39:50.448: I/tst(309): note.Favorite Is: true
04-24 19:39:50.458: I/tst(309): note.Sort Is: 5
04-24 19:39:50.458: I/tst(309): note.intID Is: 6
04-24 19:39:50.458: I/tst(309): G.notes.Size Is: 8
04-24 19:39:50.458: I/tst(309): note.title Is: شماره شناسنامه
04-24 19:39:50.458: I/tst(309): note.detail Is:
04-24 19:39:50.458: I/tst(309): note.Favorite Is: true
04-24 19:39:50.458: I/tst(309): note.Sort Is: 5
04-24 19:39:50.458: I/tst(309): note.intID Is: 8
04-24 19:39:50.458: I/tst(309): G.notes.Size Is: 9
04-24 19:39:50.458: I/tst(309): note.title Is: تاریخ تولد
04-24 19:39:50.458: I/tst(309): note.detail Is:
04-24 19:39:50.458: I/tst(309): note.Favorite Is: true
04-24 19:39:50.458: I/tst(309): note.Sort Is: 5
04-24 19:39:50.458: I/tst(309): note.intID Is: 9
04-24 19:39:50.468: I/tst(309): G.notes.title Is: تاریخ تولد
04-24 19:39:50.468: I/tst(309): G.notes.title Is: تاریخ تولد
04-24 19:39:50.468: I/tst(309): G.notes.title Is: تاریخ تولد
04-24 19:39:50.468: I/tst(309): G.notes.title Is: تاریخ تولد
04-24 19:39:50.468: I/tst(309): G.notes.title Is: تاریخ تولد
04-24 19:39:50.468: I/tst(309): G.notes.title Is: تاریخ تولد
04-24 19:39:50.468: I/tst(309): G.notes.title Is: تاریخ تولد
04-24 19:39:50.468: I/tst(309): G.notes.title Is: تاریخ تولد
04-24 19:39:50.468: I/tst(309): G.notes.title Is: تاریخ تولد

0 0
این که مشخصه !!!! شما یک حلقه for رو دارید اجرا می کنید !! شما به خروجی logcat توجه کنید. متوجه میشید چرا تکرار شده (12 سال پیش)
0 0
دوست عزیز این اتفاق نباید بی افته، من می خوام مجموعه ای از اطلاعات رو وارد G.notes کنم اما هربار با اطلاعات قبلی جایگزین می شه (12 سال پیش)
 برای این سوال 1 پاسخ وجود دارد.
پاسخ به سوال 
iSheykhi  12 سال پیش
0 0

کدها رو کمی تغییر دادم

     private void nodeSetter() {
G.notes.clear();
for (int i = 0; i < SList.TitleList.size(); i++) {
note.title = SList.TitleList.get(i);
note.detail = SList.DescList.get(i);
note.Favorite = SList.FavoriteList.get(i);
note.Sort = SList.SortList.get(i);
note.intID = SList.IDList.get(i);
note.nameOfTable = strTableNameSA;
G.notes.add(note);
Log.i("tst", "G.notes.Size Is: " + G.notes.size());
Log.i("tst", "note.title Is: " + note.title);
Log.i("tst", "note.detail Is: " + note.detail);
Log.i("tst", "note.Favorite Is: " + note.Favorite);
Log.i("tst", "note.Sort Is: " + note.Sort);
Log.i("tst", "note.intID Is: " + note.intID);
for (int j = 0; j < G.notes.size(); j++) {
Log.i("tst1", "G.notes.title Is: " + G.notes.get(i).title);
}
}
}
04-2419:39:50.408: I/tst(309): note.title  Is:نام

04-2419:39:50.418: I/tst(309): note.title Is:نامخانوادگی
04-2419:39:50.418: I/tst(309): note.title Is:نامخانوادگی

04-2419:39:50.428: I/tst(309): note.title Is:شمارهملی
04-2419:39:50.428: I/tst(309): note.title Is:شمارهملی
04-2419:39:50.428: I/tst(309): note.title Is:شمارهملی

04-2419:39:50.428: I/tst(309): note.title Is:شمارهتماس
04-2419:39:50.428: I/tst(309): note.title Is:شمارهتماس
04-2419:39:50.428: I/tst(309): note.title Is:شمارهتماس
04-2419:39:50.428: I/tst(309): note.title Is:شمارهتماس

04-2419:39:50.438: I/tst(309): note.title Is:کدپستی
04-2419:39:50.438: I/tst(309): note.title Is:کدپستی
04-2419:39:50.438: I/tst(309): note.title Is:کدپستی
04-2419:39:50.438: I/tst(309): note.title Is:کدپستی
04-2419:39:50.438: I/tst(309): note.title Is:کدپستی

04-2419:39:50.448: I/tst(309): note.title Is:ایمیل
04-2419:39:50.448: I/tst(309): note.title Is:ایمیل
04-2419:39:50.448: I/tst(309): note.title Is:ایمیل
04-2419:39:50.448: I/tst(309): note.title Is:ایمیل
04-2419:39:50.448: I/tst(309): note.title Is:ایمیل
04-2419:39:50.448: I/tst(309): note.title Is:ایمیل

04-2419:39:50.448: I/tst(309): note.title Is:نامپدر
04-2419:39:50.448: I/tst(309): note.title Is:نامپدر
04-2419:39:50.448: I/tst(309): note.title Is:نامپدر
04-2419:39:50.448: I/tst(309): note.title Is:نامپدر
04-2419:39:50.448: I/tst(309): note.title Is:نامپدر
04-2419:39:50.448: I/tst(309): note.title Is:نامپدر
04-2419:39:50.448: I/tst(309): note.title Is:نامپدر

04-2419:39:50.458: I/tst(309): note.title Is:شمارهشناسنامه
04-2419:39:50.458: I/tst(309): note.title Is:شمارهشناسنامه
04-2419:39:50.458: I/tst(309): note.title Is:شمارهشناسنامه
04-2419:39:50.458: I/tst(309): note.title Is:شمارهشناسنامه
04-2419:39:50.458: I/tst(309): note.title Is:شمارهشناسنامه
04-2419:39:50.458: I/tst(309): note.title Is:شمارهشناسنامه
04-2419:39:50.458: I/tst(309): note.title Is:شمارهشناسنامه
04-2419:39:50.458: I/tst(309): note.title Is:شمارهشناسنامه

04-2419:39:50.468: I/tst(309): G.notes.title Is:تاریختولد
04-2419:39:50.468: I/tst(309): G.notes.title Is:تاریختولد
04-2419:39:50.468: I/tst(309): G.notes.title Is:تاریختولد
04-2419:39:50.468: I/tst(309): G.notes.title Is:تاریختولد
04-2419:39:50.468: I/tst(309): G.notes.title Is:تاریختولد
04-2419:39:50.468: I/tst(309): G.notes.title Is:تاریختولد
04-2419:39:50.468: I/tst(309): G.notes.title Is:تاریختولد
04-2419:39:50.468: I/tst(309): G.notes.title Is:تاریختولد
04-2419:39:50.468: I/tst(309): G.notes.title Is:تاریختولد

هرچی هست مربوط به G.notes هست


پاسخگویی و مشاهده پاسخ های این سوال تنها برای اعضای ویژه سایت امکان پذیر است .
چنانچه تمایل دارید به همه بخش ها دسترسی داشته باشید میتوانید از این بخش لایسنس این آموزش را خریداری نمایید .