Java 在android适配器中处理来自数据库的值
我正在从android中的Java 在android适配器中处理来自数据库的值,java,android,android-layout,Java,Android,Android Layout,我正在从android中的适配器类中的数据库中检索数据,我希望数据库中的值是特定的。因为当我向上或向下滚动时,我想消除这个效果,所以在这里我需要关于如何处理适配器类中数据库SQLite中的数据的帮助 我使用了可扩展的列表视图而不是回收视图 上下滚动时,效果(该ExpandableListView组中TextView的颜色)消失 这是我的适配器类: public View getGroupView(int groupPosition, boolean isExpanded, View conver
适配器类中的数据库
中检索数据,我希望数据库中的值是特定的。因为当我向上或向下滚动时,我想消除这个效果,所以在这里我需要关于如何处理适配器类中数据库SQLite
中的数据的帮助
我使用了可扩展的列表视图
而不是回收视图
上下滚动时,效果(该ExpandableListView
组中TextView
的颜色)消失
这是我的适配器类:
public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
convertView = inflater.inflate(R.layout.expandable_for_ayats, parent, false);
//GET GROUP/SOurah item
ListAyat listAyat = (ListAyat) getGroup(groupPosition);
//SET Group Name
arabicOne = convertView.findViewById(R.id.surah_ayat);
englishOne = convertView.findViewById(R.id.english);
SavedSourah savedSourah = new SavedSourah();
Cursor cursor = mDatabase.query(
SavedSourahContract.GroceryEntry.TABLE_NAME,
null,
"sourahnumber="+savedSourah.getNumber(),
null,
null,
null,
null
);
while(cursor.moveToNext())
{
int from = Integer.parseInt(cursor.getString(2))-1;
int to = Integer.parseInt(cursor.getString(3));
int revisedState = Integer.parseInt(cursor.getString(4));
int savedState = Integer.parseInt(cursor.getString(5));
fromList.add(from);
toList.add(to);
savedList.add(savedState);
revisedList.add(revisedState);
}
if(fromList.size() > 0 && c < fromList.size() &&fromList.get(c) <= groupPosition && toList.get(c) >= groupPosition && savedList.get(c) == 1 )
{
arabicOne.setTextColor(Color.parseColor("#447EE2"));
}
else{
if(fromList.size() > 0 && c < fromList.size()&&fromList.get(c) <= groupPosition &&toList.get(c) >= groupPosition && revisedList.get(c) == 1)
{
arabicOne.setTextColor(Color.parseColor("#A82020"));
}
else{
arabicOne.setTextColor(Color.parseColor("#905501"));
englishOne.setTextColor(Color.parseColor("#64615D"));
c++;
Log.i("newcounteragain" , "here : " + c);
Log.i("newcounteragain" , "here : " + fromList.size());
}
}
if(c > reading_sourahForAllList.fromList2.size()) {
c = 0;
fromList = new ArrayList<>();
toList = new ArrayList<>();
savedList = new ArrayList<>();
revisedList = new ArrayList<>();
}
arabicOne.setText(listAyat.getAyah());
englishOne.setText(listAyat.getAyahInEnglish());
return convertView;
}
public View getGroupView(int-groupPosition、boolean-isExpanded、View-convertView、View-group-parent){
convertView=充气机。充气(R.layout.expandable\u for\u ayats,父级,false);
//获取组/SOurah项目
ListAyat ListAyat=(ListAyat)getGroup(groupPosition);
//设置组名
arabicOne=convertView.findViewById(R.id.surah_-ayat);
EnglishPhone=convertView.findviewbyd(R.id.english);
SavedSourah SavedSourah=新的SavedSourah();
Cursor=mDatabase.query(
SavedSourceContract.GroceryEntry.TABLE\u名称,
无效的
“sourahnumber=“+savedSourah.getNumber(),
无效的
无效的
无效的
无效的
);
while(cursor.moveToNext())
{
int from=Integer.parseInt(cursor.getString(2))-1;
int to=Integer.parseInt(cursor.getString(3));
int revisedState=Integer.parseInt(cursor.getString(4));
int savedState=Integer.parseInt(cursor.getString(5));
fromList.add(from);
toList.add(to);
savedList.add(savedState);
修订列表。添加(修订状态);
}
if(fromList.size()>0&&c0&&c读取\u sourahForAllList.fromList2.size()){
c=0;
fromList=newarraylist();
toList=新的ArrayList();
savedList=newarraylist();
ReviedList=新的ArrayList();
}
arabicOne.setText(listAyat.getAyah());
英语单词setText(listAyat.getayhinenglish());
返回视图;
}