Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to delete item with icon from adapter
    primarykey
    data
    text
    <p>I am trying to delete from adapter an icon with item(text) from adapter. I know it looks like a simple task and I did it but still have some bug on it. Its looks like the item that I delete them get strange that first icon in the list and the last one get the same icon. Here's the code:</p> <pre><code>ListRssLinkAndTitle=(ArrayList)dbAdpter.getWantedItemsList(this,"RssTitle","link","Rtl","image");//get wanted items from db for (int j=0;j&lt;ListRssLinkAndTitle.size();j++) listKeys.add(ListRssLinkAndTitle.get(j).title); for (int i=0;i&lt;ListRssLinkAndTitle.size();i++) Icon.add(ListRssLinkAndTitle.get(i).icon); listAdapter = new ListRssAdpter(this, R.layout.titlesrss, listKeys,Icon); lv.setAdapter(listAdapter); lv.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) { if (0&lt;dbAdpter.deleteRssItem(ListRssLinkAndTitle.get(position).title,ListRssLinkAndTitle.get(position).url)) { ListRssLinkAndTitle.remove(position); listAdapter.items.remove(position); listAdapter.FavIconList.remove(position); listAdapter.notifyDataSetChanged(); } else Toast.makeText(getApplicationContext(), getResources().getString(R.string.operationFaild),0).show(); } } }); </code></pre> <p>and the adapter:</p> <pre><code>public class ListRssAdpter extends ArrayAdapter { private Context mContext; private int id; public List&lt;String&gt; items; public List&lt;byte[]&gt; FavIconList; public boolean iconRemove=false; public int IconHigh=-1;// if -1 not in use //constractor for fav icon public ListRssAdpter(Context context, int textViewResourceId, List&lt;String&gt; list,List&lt;byte[]&gt; icon) { super(context, textViewResourceId, list); mContext = context; id = textViewResourceId; items = list; this.FavIconList=icon; } public View getView(int position, View v, ViewGroup parent) { View mView = v; if (mView==null) { LayoutInflater vi = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); mView = vi.inflate(id, null); } ImageView removeIcon = (ImageView)mView.findViewById(R.id.iconremove); ImageView favIcon = (ImageView)mView.findViewById(R.id.iconfav); if (iconRemove) { removeIcon.setVisibility(View.VISIBLE); favIcon.setVisibility(favIcon.GONE); } else { if (FavIconList.get(position)!=null) { Bitmap bitmap = BitmapFactory.decodeByteArray(FavIconList.get(position), 0, FavIconList.get(position).length); favIcon.setImageBitmap(bitmap); } else BitmapFactory.decodeResource(mView.getContext().getResources(),R.drawable.rss); removeIcon.setVisibility(removeIcon.GONE); favIcon.setVisibility(favIcon.VISIBLE); } TextView tx = (TextView) mView.findViewById(R.id.textView); //if this view is on main screen if (tx == null) { tx = ((TextView) mView); } if (this.IconHigh!=-1) tx.setHeight(this.IconHigh); //this.setTextSize(TypedValue.COMPLEX_UNIT_PX, size); tx.setText(items.get(position)); return mView; } } </code></pre> <p>If you can't find a logic error maybe you can give me a simple example working code :)</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.
    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