Android:Get button clicked in custom listview -


i have used lazyadapter creating custom listview. require use image can clicked dial number. error coming in onclick method of image. startactivity says "there no such method in lazyadapter". posting code below.

public class lazyadapter extends baseadapter {  private activity activity; private string[] data; private string[] project;  context con;  public lazyadapter(context con) {     this.con = con; }   public lazyadapter(activity a, string[] pic, string[] p) {     activity = a;     data = pic;     project = p;     inflater = (layoutinflater) activity             .getsystemservice(context.layout_inflater_service);     imageloader = new imageloader(activity.getapplicationcontext()); }  public int getcount() {     return data.length; }  public object getitem(int position) {     return position; }  public long getitemid(int position) {     return position; }  public view getview(final int position, view convertview, viewgroup parent) {      layoutinflater inflater = (layoutinflater) con             .getsystemservice(context.layout_inflater_service);     view vi = convertview;      if (convertview == null)         vi = inflater.inflate(r.layout.item_result_page, null);        ------more code----     imageview ivcall = (imageview) vi.findviewbyid(r.id.imageviewircall);     ivcall.setonclicklistener(new view.onclicklistener() {          @override         public void onclick(view v) {             string uri = "tel:9818222333";              intent intent = new intent(intent.action_dial);              intent.setdata(uri.parse(uri));              startactivity(intent);         }     });      return vi; } 

i have refered link error there in startactivity. so link

simply need append context of activity while calling intent!

within onclick@

use#

intent intent = new intent(intent.action_dial);              intent.setdata(uri.parse(uri));              activity.startactivity(intent); 

instead#

intent intent = new intent(intent.action_dial);              intent.setdata(uri.parse(uri));              startactivity(intent); 

additionally#

use viewhoder inside getview() method , set tag button , tag inside onclick correct position of view.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -