Note that there are some explanatory texts on larger screens.

plurals
  1. POfinish activity from custom BaseAdapter
    text
    copied!<p>In my android application I have custom listview with an image and textview. In extended BaseAdapter under getView method click events of textview and image are associated with onClick method using setOnClickListener as shown in code below</p> <pre><code>public View getView(int position, View convertView, ViewGroup viewGroup) { String entry = listWords.get(position); if(convertView == null) { LayoutInflater inflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); convertView = inflater.inflate(R.layout.history_row, null); } TextView txtWordView = (TextView) convertView.findViewById(R.id.txtWordView); txtWordView.setText(entry); txtWordView.setOnClickListener(this); txtWordView.setTag(entry); ImageView imgRemove = (ImageView) convertView.findViewById(R.id.del_x); imgRemove.setOnClickListener(this); imgRemove.setTag(entry); return convertView; } </code></pre> <p>and </p> <pre><code>public void onClick(View view) { try { if(view instanceof TextView){ //Here i would like this to finish this activity with result being sent to main //activity - something like this //Intent result = getIntent(); //result.putExtra("word", _strList.get(location)); //setResult(RESULT_OK, result); //finish(); } else { String entry = (String) view.getTag(); listWords.remove(entry); History objHistory = new History(this.context); objHistory.clearHistory(entry); } notifyDataSetChanged(); } catch (Exception e) { } } </code></pre> <p>When clicking on image it acutally deletes that entry from List which works fine, but on clicking textview i would like to return the text of clicked textview to main activity but I am unable to achieve this, although I can do this from setOnItemClickListener of this custom listview acitivity.</p>
 

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