java - No public RealmResults<E> Constructor? -
i've got table has realm objects i'm calling foo. 1 of columns of foo points realm object, bar. want query table foo , pick out of bar objects need, , add them realmbaseadapter.
however, knowledge, realmbaseadapter takes realmresults list in it's constructor. how form realmresults of bar without querying bar table? or, how query foo table , realmresults of bar?
for example, had table of product's , product segments, e.g. rice krispies, corn flakes, fruit loops belong cereal product segment. wish query table of products specification, , list of product segments contained in result.
since there no way directly, ended making own adapter.
public class baradapter extends arrayadapter<bar> { //code instantiate adapter, inflate views, etc } this part trivial, hard work done curating query foo-->bar me results wanted. ended looking this,
// footype wanted ween out foo results on before // selecting bar objects. realmquery<foo> foorealmquery = realm .where(foo.class) .equalto("footype", "desired type") .or() .equalto("footype", "other type"); realmresults<foo> foolist = foorealmquery.findall(); list<bar> barlist = new arraylist<bar>(); (foo foo : foolist) { bar bar = foo.getbar(); if (!barlist.contains(bar)) { barlist.add(bar); log.d(tag, "added " + bar.getname()); } else { log.d(tag, "i had bar"); } } adapter = new baradapter(this, barlist); listview.setadapter(adapter); now things work well. also, realm fast enough can query right i'm creating adapter , see no performance lag :)
Comments
Post a Comment