Saturday, 15 February 2014

Run Method from onClick of a List Item Android -



Run Method from onClick of a List Item Android -

how run method onclick of list item?

my method called callemergency()

public void callemergency(view arg0) { string phone_no = "911"; intent callintent = new intent(intent.action_call); callintent.setdata(uri.parse("tel:" + phone_no)); callintent.setflags(intent.flag_activity_new_task); startactivity(callintent); }

i can start other activities with:

public void onitemclick(adapterview<?> parent, view view, int position, long id) { intent = new intent(getapplicationcontext(), activity.class); startactivity(i);}

but i'd run callemergency() method.

simply use:

public void onitemclick(adapterview<?> parent, view view, int position, long id) { callemergency(null); }

(please read java naming conventions, state methods callemergency() should start lower case letter.)

android android-listview onclick

No comments:

Post a Comment