다른 "Mother"Listview 안에 여러 Listviews를 가져 오려고했습니다.ExpandableListView 또는 중첩 된 ListView의 다중 ListView
나는 ListView가 생성 된 클래스와이 뷰를 호출하는 Activity 클래스를 가지고있다. 내가하고 관리하는 유일한 항목 @ ListPerms와 "어머니"(개체가 같아요)
다음이 (지금) 복수의 ListView
public ListPerms(Context context, String a, int docid) {
super(context);
table=a;
did=docid;
list= (ListView) findViewById(R.id.specific_perm_list);
getdata(list,ar_list);
}
private void getdata(ListView list, ArrayList<String> arlist){
Database openHelper = new Database(getContext());
myDB = openHelper.getReadableDatabase();
myDB=SQLiteDatabase.openDatabase("data/data/com.example.login2/databases/aeglea", null, SQLiteDatabase.OPEN_READONLY);
try{fill(list,arlist);}catch(Exception e){Log.e("NAT EXISTANT","THIS->"+e);}
}
private void fill(ListView list, ArrayList<String> arlist){
Cursor temp = null;
Cursor buffer = null;
String type_from_table = null;
String[] items = null;
if(table=="med") {type_from_table = "medication";}
if(table=="test") {type_from_table = "test";}
if(table=="all") {type_from_table = "allergy";}
if(table=="proc") {type_from_table = "procedure";}
if(table=="cond") {type_from_table = "condition";}
if(table=="vacc") {type_from_table = "vaccine";}
temp = fetchOption("SELECT * FROM permission WHERE did="+did+" AND type='"+type_from_table+"'");
if(temp.getCount()>0){
buffer = fetchOption("SELECT * FROM user_"+table+" WHERE id="+temp.getString(temp.getColumnIndex("fileid")));
items = new String[] {buffer.getString(buffer.getColumnIndex("name"))};
arlist.addAll(Arrays.asList(items));
listAdapter = new ArrayAdapter<String>(getContext(), R.layout.item, arlist);
for(int i=1;i<temp.getCount();i++){
temp.moveToNext();
buffer = fetchOption("SELECT * FROM user_"+table+" WHERE id="+temp.getString(temp.getColumnIndex("fileid")));
listAdapter.add(buffer.getString(buffer.getColumnIndex("name")));
}
list.setAdapter(listAdapter);
}else{
items = new String[] { "None."};
arlist.addAll(Arrays.asList(items));
listAdapter = new ArrayAdapter<String>(getContext(), R.layout.item, arlist);
list.setAdapter(listAdapter);
}
}
그리고 활동 클래스는 다음과 내 클래스입니다 채우기입니다
{.... LV, LV} 나는 ExpandableListView를 가지고,하지만 난 ELV가있는 ListView {LV, 레벨 ...} 또는 ExpandableListView을 수행하는 방법에
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.docp);
general = (ExpandableListView) findViewById(R.id.Tot_perm_list);
//random data
}
protected void onResume(){
super.onResume();
ListPerms me = new ListPerms(getApplicationContext(),"med",did);
ListPerms te = new ListPerms(getApplicationContext(),"test",did);
ListPerms all = new ListPerms(getApplicationContext(),"all",did);
ListPerms proc = new ListPerms(getApplicationContext(),"proc",did);
ListPerms cond = new ListPerms(getApplicationContext(),"cond",did);
ListPerms vacc = new ListPerms(getApplicationContext(),"vacc",did);
me.setActivated(isChild());
te.setActivated(isChild());
all.setActivated(isChild());
proc.setActivated(isChild());
cond.setActivated(isChild());
vacc.setActivated(isChild());
list.add(me);
list.add(te);
list.add(all);
list.add(proc);
list.add(cond);
list.add(vacc);
general.setAdapter(listAdapter);
general.addChildrenForAccessibility(list);
//what do I do
}
조언을 어떻게 작동하는지 이해하는 것이 정말 멍청한 놈이야
고마워요! 나는 그것을 시도 할 것이다. 데이터를 많은 ListViews로 파싱하는 대신 ExpandableListView에 데이터를 채우는 방법을 볼 수 없습니다. – MayTheSchwartzBeWithYou
hm, 예 : asynctask를 사용하여 하위 어댑터를 만들고 데이터를 준비합니다. 또는 http://developer.android.com/guide/components/loaders.html - CursorLoader를 통해 mChildAdapters에 새로운 하위 어댑터를 추가하면 데이터가 준비됩니다 (하나씩) - 빈 화면이 표시됩니다. – sandrstar