android - button in custom adapter won't take me to the next screen -


i have new intent in custom adapter. if button clicked then, should take me new screen. but, keep getting runtimeexception

    public void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_near_me);      if (savedinstancestate == null) {         getfragmentmanager().begintransaction()         .add(r.id.container, new placeholderfragment()).commit();     } }  public placeholderfragment() {         }          @override         public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate)          {             view rootview = inflater.inflate(r.layout.fragment_near_me, container, false);              getlistadresses(39, -77);             return rootview;         }  public arraylist<arraylist<string>> getlistadresses(double str, double str1)         {             arraylist<arraylist<string>> ans = new arraylist<arraylist<string>>();             (int = 0; < list.size(); i++)             {                 /**                  * 10 = lat                  * 9 = long                  */                 double dlat = double.parsedouble(list.get(i).get(10).tostring());                 double dlng = double.parsedouble(list.get(i).get(9).tostring());                 if ((dlat < (lat + 1) && dlat > (lat - 1))                          && (dlng < (lng + 1) && dlng > (lng - 1)))                 {                     ans.add(list.get(i));                 }             }             return ans;         }              public static class row     {         string storename;         string streetadress;         string location;         string country;          row(string str1, string str2, string str3, string str4)         {             storename = str1;             streetadress = str2;             location = str3;             country = str4;         }     }      public static class customadapter extends baseadapter     {         arraylist<row> speclist;         context conty;          customadapter(context c)         {             conty = c;             speclist = new arraylist<row>();             arraylist<string> storename = new arraylist<string>();             arraylist<string> streetadress = new arraylist<string>();             arraylist<string> location = new arraylist<string>();             arraylist<string> country = new arraylist<string>();             (int = 0; < ar.size(); i++)             {                 storename.add(ar.get(i).get(0).tostring());                 streetadress.add(ar.get(i).get(2).tostring());                 location.add(ar.get(i).get(3).tostring() + ", "                  + ar.get(i).get(4).tostring() + " " + ar.get(i).get(5).tostring());                 country.add(ar.get(i).get(7).tostring());             }              (int = 0; < ar.size(); i++)             {                 speclist.add(new row(storename.get(i), streetadress.get(i),                          location.get(i), country.get(i)));             }         }                 @override         public int getcount() {             // todo auto-generated method stub             return speclist.size();         }          @override         public object getitem(int position) {             // todo auto-generated method stub             return speclist.get(position);         }          @override         public long getitemid(int position) {             // todo auto-generated method stub             return position;         }          @override         public view getview(int position, view convertview, viewgroup parent) {             // todo auto-generated method stub             layoutinflater inflater = (layoutinflater) conty.getsystemservice(context.layout_inflater_service);             final view rw = inflater.inflate(r.layout.row, parent, false);             textview name = (textview) rw.findviewbyid(r.id.textview1);             textview adress = (textview) rw.findviewbyid(r.id.textview2);             textview location = (textview) rw.findviewbyid(r.id.textview3);             textview country = (textview) rw.findviewbyid(r.id.textview4);             final row temp = speclist.get(position);             name.settext(temp.storename);             adress.settext(temp.streetadress);             location.settext(temp.location);             country.settext("  phone:" + temp.country);             button call = (button) rw.findviewbyid(r.id.button1);             call.setonclicklistener(new onclicklistener(){                  @override                 public void onclick(view v) {                     uri u = uri.parse("tel:" + temp.country);                     intent = new intent(intent.action_call, u);                     rw.getcontext().startactivity(i);                 }              });              button map = (button) rw.findviewbyid(r.id.button2);              map.setonclicklistener(new    onclicklistener(){                      @override                     public void onclick(view v) {                                 intent = new intent(rw.getcontext(), nearresults.class);                                rw.getcontext().startactivity(i);                      }                  });             return rw;         } 

this code inside custom adapter listview. written in near.class.

here's logcat:

06-03 15:28:53.849: e/androidruntime(22807): fatal exception: main 06-03 15:28:53.849: e/androidruntime(22807): java.lang.runtimeexception: unable start activity componentinfo{com.example.myapp/com.example.myapp.nearresults}: java.lang.illegalargumentexception: no view found id 0x7f060014 (com.example.myapp:id/container) fragment placeholderfragment{4292b3b0 #0 id=0x7f060014} 06-03 15:28:53.849: e/androidruntime(22807):    @ android.app.activitythread.performlaunchactivity(activitythread.java:2305) 06-03 15:28:53.849: e/androidruntime(22807):    @ android.app.activitythread.handlelaunchactivity(activitythread.java:2359) 06-03 15:28:53.849: e/androidruntime(22807):    @ android.app.activitythread.access$700(activitythread.java:165) 06-03 15:28:53.849: e/androidruntime(22807):    @ android.app.activitythread$h.handlemessage(activitythread.java:1326) 06-03 15:28:53.849: e/androidruntime(22807):    @ android.os.handler.dispatchmessage(handler.java:99) 06-03 15:28:53.849: e/androidruntime(22807):    @ android.os.looper.loop(looper.java:137) 06-03 15:28:53.849: e/androidruntime(22807):    @ android.app.activitythread.main(activitythread.java:5455) 06-03 15:28:53.849: e/androidruntime(22807):    @ java.lang.reflect.method.invokenative(native method) 06-03 15:28:53.849: e/androidruntime(22807):    @ java.lang.reflect.method.invoke(method.java:525) 06-03 15:28:53.849: e/androidruntime(22807):    @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:1187) 06-03 15:28:53.849: e/androidruntime(22807):    @ com.android.internal.os.zygoteinit.main(zygoteinit.java:1003) 06-03 15:28:53.849: e/androidruntime(22807):    @ dalvik.system.nativestart.main(native method) 06-03 15:28:53.849: e/androidruntime(22807): caused by: java.lang.illegalargumentexception: no view found id 0x7f060014 (com.example.vipar:id/container) fragment placeholderfragment{4292b3b0 #0 id=0x7f060014} 06-03 15:28:53.849: e/androidruntime(22807):    @ android.app.fragmentmanagerimpl.movetostate(fragmentmanager.java:895) 06-03 15:28:53.849: e/androidruntime(22807):    @ android.app.fragmentmanagerimpl.movetostate(fragmentmanager.java:1075) 06-03 15:28:53.849: e/androidruntime(22807):    @ android.app.backstackrecord.run(backstackrecord.java:682) 06-03 15:28:53.849: e/androidruntime(22807):    @ android.app.fragmentmanagerimpl.execpendingactions(fragmentmanager.java:1455) 06-03 15:28:53.849: e/androidruntime(22807):    @ android.app.activity.performstart(activity.java:5381) 06-03 15:28:53.849: e/androidruntime(22807):    @ android.app.activitythread.performlaunchactivity(activitythread.java:2276) 06-03 15:28:53.849: e/androidruntime(22807):    ... 11 more 

this xml nearme

<relativelayout xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:tools="http://schemas.android.com/tools"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:paddingbottom="@dimen/activity_vertical_margin"     android:paddingleft="@dimen/activity_horizontal_margin"     android:paddingright="@dimen/activity_horizontal_margin"     android:paddingtop="@dimen/activity_vertical_margin"     tools:context="com.example.vipar.nearme$placeholderfragment" >      <listview         android:id="@+id/listview1"         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:layout_centerhorizontal="true"         android:layout_centervertical="true" >     </listview>  </relativelayout> 

xml nearresults:

<relativelayout xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="fill_parent"     android:layout_height="fill_parent" >      <textview         android:id="@+id/textview1"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_alignparentleft="true"         android:layout_alignparenttop="true"         android:layout_marginleft="90dp"         android:layout_margintop="161dp"         android:text="small text"         android:textappearance="?android:attr/textappearancesmall" />  </relativelayout> 

xml row:

<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="match_parent"     android:layout_height="match_parent" >      <textview         android:id="@+id/textview1"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_alignparentleft="true"         android:layout_alignparenttop="true"         android:text="medium text"         android:textappearance="?android:attr/textappearancemedium" />      <textview         android:id="@+id/textview2"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_alignparentleft="true"         android:layout_below="@+id/textview1"         android:text="textview" />      <textview         android:id="@+id/textview3"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_alignparentleft="true"         android:layout_below="@+id/textview2"         android:text="textview" />      <textview         android:id="@+id/textview4"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_alignparentleft="true"         android:layout_below="@+id/textview3"         android:text="textview" />      <imageview         android:id="@+id/imageview1"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_alignbottom="@+id/textview4"         android:layout_alignparentright="true"         android:layout_marginright="14dp"         android:adjustviewbounds="true"         android:src="@drawable/logo" />      <button         android:id="@+id/button1"         style="?android:attr/buttonstylesmall"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_alignparentleft="true"         android:layout_below="@+id/textview4"         android:text="call" />      <button         android:id="@+id/button2"         style="?android:attr/buttonstylesmall"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_alignbaseline="@+id/button1"         android:layout_alignbottom="@+id/button1"         android:layout_alignright="@+id/imageview1"         android:text="map it" />  </relativelayout> 

update (2): have no layout/viewgroup id equal 'container' in activity_near_me.xml. add line "android:id="@+id/container" layout contain fragment

update: think issue related this can't tell without seeing how set view hierarchy in activity , how add fragment


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -