Note that there are some explanatory texts on larger screens.

plurals
  1. POPress button in listView adapter to get data in this row
    primarykey
    data
    text
    <p>I have a listView that shows data that in sqlite, I'm using baseAdapter. The list row contains text and button. </p> <p>I press the button in each row to give me each data of the selected row from the database (not pressing the row itself)</p> <p>This is code of listView:</p> <pre><code>tipsList = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;(); list = (ListView) rootView.findViewById(R.id.tipList); do { map = new HashMap&lt;String, String&gt;(); map.put(DAO.TIP_ID, c.getString(c.getColumnIndex(c.getColumnName(0)))); map.put(DAO.TIP_CONTENT, c.getString(c.getColumnIndex(c.getColumnName(1)))); map.put(DAO.TIP_FAVORITE, c.getString(c.getColumnIndex(c.getColumnName(2)))); // adding HashList to ArrayList tipsList.add(map); } while (c.moveToNext()); tipsAdapter = new TipsAdapter(getActivity(), tipsList, tipType, db); list.setAdapter(tipsAdapter); </code></pre> <p>And this is code of TipsAdapter.java</p> <pre><code>public class TipsAdapter extends BaseAdapter { private Activity activity; private ArrayList&lt;HashMap&lt;String, String&gt;&gt; data; private static LayoutInflater inflater = null; Context context; Typeface tf; String tipID; String tipText; String isFavorite; DAO db; HashMap&lt;String, String&gt; quote; int selectedTipType; public TipsAdapter(Activity a, ArrayList&lt;HashMap&lt;String, String&gt;&gt; d, int selectedTipType, DAO db) { activity = a; data = d; context = a; this.selectedTipType = selectedTipType; this.db = db; inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE); } // ============================================================================== public int getCount() { return data.size(); } // ============================================================================== public Object getItem(int position) { return position; } // ============================================================================== public long getItemId(int position) { return position; } // ============================================================================== public View getView(int position, View convertView, ViewGroup parent) { View vi = convertView; if (convertView == null) vi = inflater.inflate(R.layout.tip_list_row, null); TextView tipContent = (TextView) vi.findViewById(R.id.tip_text); // tip final ImageView favStar = (ImageView) vi.findViewById(R.id.favorite_star); tf = Typeface.createFromAsset(activity.getAssets(), "fonts/bauhausm_0.ttf"); tipContent.setTypeface(tf); quote = new HashMap&lt;String, String&gt;(); quote = data.get(position); tipText = quote.get(DAO.TIP_CONTENT).trim(); favStar.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { // I want here get all data like tipId - tipText - tipFavotite of the current row in toast } }); return vi; } } </code></pre> <p>How to get the data of the current row when press the button? Hope anyone got my mean. Thanks in advance.</p>
    singulars
    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