Note that there are some explanatory texts on larger screens.

plurals
  1. POhow can I sort items in BaseAdapter before I setAdapter?
    primarykey
    data
    text
    <p>I have a baseAdapter class that adds data to a Gridview. Please is there a way to sort the list before it is added to the Adapter?</p> <pre><code>Comm_AppsList=new ArrayList&lt;Appis_Infos&gt;(); Comm_AppsList.add(new Appis_Infos(BitmapFactory.decodeResource(com_res, R.drawable.skype), "Skype","com.skype.raider")); Comm_AppsList.add(new Appis_Infos(BitmapFactory.decodeResource(com_res, R.drawable.yahoomessenger),"Messenger","com.yahoo.mobile.client.android.im")); Comm_AppsList.add(new Appis_Infos(BitmapFactory.decodeResource(com_res, R.drawable.whatsappm),"WhatsApp","com.whatsapp")); Comm_AppsList.add(new Appis_Infos(BitmapFactory.decodeResource(com_res, R.drawable.yahoomail),"Mail","com.yahoo.mobile.client.android.mail")); Com_gridview.setAdapter(new CommAppis_Adapter(this, Comm_AppsList)); </code></pre> <p>And here is the BaseAdapter</p> <pre><code> class CommAppis_Adapter extends BaseAdapter{ private Context AIcontext; private List&lt;Appis_Infos&gt;AdList; CommAppis_Adapter(Context Aicontext, List&lt;Appis_Infos&gt; aDlist){ AIcontext=Aicontext; AdList=aDlist; } @Override public int getCount() { // TODO Auto-generated method stub return AdList.size(); } @Override public Object getItem(int it_position) { // TODO Auto-generated method stub return AdList.get(it_position); } @Override public long getItemId(int id_position) { // TODO Auto-generated method stub return id_position; } @Override public View getView(int Vposition, View Aview, ViewGroup Vparent) { // TODO Auto-generated method stub Appis_Infos appsData=AdList.get(Vposition); Comm_Viewholder holder=null; if(Aview==null){ LayoutInflater apps_inflater=LayoutInflater.from(AIcontext); Aview=apps_inflater.inflate(R.layout.comm_appis, null); holder=new Comm_Viewholder(); holder.apps_icons=(ImageView)Aview.findViewById(R.id.comm_imageview); holder.apps_name=(TextView)Aview.findViewById(R.id.comm_tvName); Aview.setTag(holder); }else{ holder=(Comm_Viewholder)Aview.getTag(); } holder.apps_icons.setImageBitmap(appsData.getIcon()); holder.apps_name.setText(appsData.getName()); return Aview; } } </code></pre> <p>Please how do I sort (Programmatically because my List is very long.I just croped it) these items before I add them.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload