Re: [android-developers] ListFragment fails on setContentView
On Sun, Mar 18, 2012 at 9:25 PM, Jim Andresakis jimandresa...@gmail.com wrote: Hey thanks for jumping in Mark. So no matter what subclass of fragment Im using I always call it from xml using just fragment ? Yes, with a class attribute identifying the implementation. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy _The Busy Coder's Guide to *Advanced* Android Development_ Version 2.5 Available! -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] ListFragment fails on setContentView
If you have a seperate layout.xml for your listfragment, then maybe you are missing @android:id/list as id for your listview? On Mon, Mar 19, 2012 at 11:12 AM, Mark Murphy mmur...@commonsware.comwrote: On Sun, Mar 18, 2012 at 9:25 PM, Jim Andresakis jimandresa...@gmail.com wrote: Hey thanks for jumping in Mark. So no matter what subclass of fragment Im using I always call it from xml using just fragment ? Yes, with a class attribute identifying the implementation. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy _The Busy Coder's Guide to *Advanced* Android Development_ Version 2.5 Available! -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] ListFragment fails on setContentView
Yeah I had it that way at one point but I switched it based on some examples I saw online. I think at this point it'd be better for me to start over because Im so confused with my code the way it is. That way I can just start with one example somewhere. If you guys know of a great simple example I could see to better understand using a fragment with a listview or a listfragment Id much appreciate it. Thanks again for the pointers :) On Monday, March 19, 2012 3:44:02 AM UTC-7, hoeggi wrote: If you have a seperate layout.xml for your listfragment, then maybe you are missing @android:id/list as id for your listview? On Mon, Mar 19, 2012 at 11:12 AM, Mark Murphy mmur...@commonsware.comwrote: On Sun, Mar 18, 2012 at 9:25 PM, Jim Andresakis jimandresa...@gmail.com wrote: Hey thanks for jumping in Mark. So no matter what subclass of fragment Im using I always call it from xml using just fragment ? Yes, with a class attribute identifying the implementation. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy _The Busy Coder's Guide to *Advanced* Android Development_ Version 2.5 Available! -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] ListFragment fails on setContentView
On Mon, Mar 19, 2012 at 6:58 PM, Jim Andresakis jimandresa...@gmail.com wrote: Yeah I had it that way at one point but I switched it based on some examples I saw online. I think at this point it'd be better for me to start over because Im so confused with my code the way it is. That way I can just start with one example somewhere. If you guys know of a great simple example I could see to better understand using a fragment with a listview or a listfragment Id much appreciate it. Mine aren't especially simple, a problem I am addressing in The Big Book Reboot. So, perhaps try: http://mobile.tutsplus.com/tutorials/android/android-sdk_fragments/ -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy Android Training in NYC: http://marakana.com/training/android/ -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] ListFragment fails on setContentView
ListFragment is not a valid element. That says hey, go find android.view.ListFragment and use it here, and there is no such class. You add fragments to a layout via fragment: http://developer.android.com/guide/topics/fundamentals/fragments.html#Adding On Sun, Mar 18, 2012 at 7:29 AM, Jim Andresakis jimandresa...@gmail.com wrote: Ive been trying to get a listview working within a fragment all day. I dont know why but for some reason the way Im trying to do it, it just never wants to inflate the view. Im using actionbarsherlock if that makes a difference but I dont think so. Heres the class where my layout fails: public class GraffSearch extends FragmentActivity implements ActionBar.TabListener{ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.searchlayout);//-fails here final ActionBar ab = getSupportActionBar(); for (int i = 1; i 4; i++) { ab.addTab(ab.newTab().setText(Tab + i).setTabListener(this)); } ab.show(); if (ab.getNavigationMode() != ActionBar.NAVIGATION_MODE_TABS) { ab.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); } } @Override public void onTabReselected(Tab tab, FragmentTransaction ft) { // TODO Auto-generated method stub } @Override public void onTabSelected(Tab tab, FragmentTransaction ft) { //Toast.makeText(this, tabs work +tab.getPosition()+ user id is +avrid, Toast.LENGTH_LONG).show(); SearchListFrag fragment = (SearchListFrag) getSupportFragmentManager().findFragmentById(R.id.searchfrag); //fragment.updateUrl(tab.getPosition(), avrid); } @Override public void onTabUnselected(Tab tab, FragmentTransaction ft) { // TODO Auto-generated method stub } } and heres the layout were I call my fragment. ?xml version=1.0 encoding=utf-8? LinearLayout xmlns:android=http://schemas.android.com/apk/res/android; android:layout_width=match_parent android:layout_height=match_parent android:orientation=vertical ListFragment android:id=@+id/searchfrag android:layout_width=0dip android:layout_height=match_parent android:name=graffit.main.SearchListFrag android:layout_weight=1/ListFragment /LinearLayout Ive tried a few different setups going back and forth from using a regular fragment and a listfragment with the same result. Heres the logcat. 03-18 03:38:49.363: E/AndroidRuntime(8385): FATAL EXCEPTION: main 03-18 03:38:49.363: E/AndroidRuntime(8385): java.lang.RuntimeException: Unable to start activity ComponentInfo{graffit.main/graffit.main.GraffSearch}: android.view.InflateException: Binary XML file line #9: Error inflating class ListFragment 03-18 03:38:49.363: E/AndroidRuntime(8385): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1696) 03-18 03:38:49.363: E/AndroidRuntime(8385): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1716) 03-18 03:38:49.363: E/AndroidRuntime(8385): at android.app.ActivityThread.access$1500(ActivityThread.java:124) 03-18 03:38:49.363: E/AndroidRuntime(8385): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:968) 03-18 03:38:49.363: E/AndroidRuntime(8385): at android.os.Handler.dispatchMessage(Handler.java:99) 03-18 03:38:49.363: E/AndroidRuntime(8385): at android.os.Looper.loop(Looper.java:130) 03-18 03:38:49.363: E/AndroidRuntime(8385): at android.app.ActivityThread.main(ActivityThread.java:3806) 03-18 03:38:49.363: E/AndroidRuntime(8385): at java.lang.reflect.Method.invokeNative(Native Method) 03-18 03:38:49.363: E/AndroidRuntime(8385): at java.lang.reflect.Method.invoke(Method.java:507) 03-18 03:38:49.363: E/AndroidRuntime(8385): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) 03-18 03:38:49.363: E/AndroidRuntime(8385): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) 03-18 03:38:49.363: E/AndroidRuntime(8385): at dalvik.system.NativeStart.main(Native Method) 03-18 03:38:49.363: E/AndroidRuntime(8385): Caused by: android.view.InflateException: Binary XML file line #9: Error inflating class ListFragment 03-18 03:38:49.363: E/AndroidRuntime(8385): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:581) 03-18 03:38:49.363: E/AndroidRuntime(8385): at android.view.LayoutInflater.rInflate(LayoutInflater.java:623) 03-18 03:38:49.363: E/AndroidRuntime(8385): at android.view.LayoutInflater.inflate(LayoutInflater.java:408) 03-18 03:38:49.363: E/AndroidRuntime(8385): at android.view.LayoutInflater.inflate(LayoutInflater.java:320) 03-18 03:38:49.363: E/AndroidRuntime(8385): at android.view.LayoutInflater.inflate(LayoutInflater.java:276) 03-18 03:38:49.363: E/AndroidRuntime(8385): at android.support.v4.app.FragmentActivity.setContentView(FragmentActivity.java:421) 03-18
Re: [android-developers] ListFragment fails on setContentView
Am 18.03.12 12:29, schrieb Jim Andresakis: and heres the layout were I call my fragment. ?xml version=1.0 encoding=utf-8? LinearLayout xmlns:android=http://schemas.android.com/apk/res/android; android:layout_width=match_parent android:layout_height=match_parent android:orientation=vertical ListFragment android:id=@+id/searchfrag android:layout_width=0dip android:layout_height=match_parent android:name=graffit.main.SearchListFrag android:layout_weight=1/ListFragment /LinearLayout java.lang.RuntimeException: Unable to start activity ComponentInfo{graffit.main/graffit.main.GraffSearch}: android.view.InflateException: Binary XML file line #9: Error inflating class ListFragment ListFragment is not a subclass of View so it can't inflated. You have to use ListView in your layout xml file. http://android-developers.blogspot.de/2011/02/android-30-fragments-api.html http://developer.android.com/resources/samples/Support4Demos/src/com/example/android/supportv4/app/FragmentListArraySupport.html Ralph -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] ListFragment fails on setContentView
Hey thanks for jumping in Mark. So no matter what subclass of fragment Im using I always call it from xml using just fragment ? I switched my code up using that but now I get an error in my logcat complaining about a resource exception resource not found on my listview. On Sunday, March 18, 2012 4:56:24 AM UTC-7, Mark Murphy (a Commons Guy) wrote: ListFragment is not a valid element. That says hey, go find android.view.ListFragment and use it here, and there is no such class. You add fragments to a layout via fragment: http://developer.android.com/guide/topics/fundamentals/fragments.html#Adding On Sun, Mar 18, 2012 at 7:29 AM, Jim Andresakis jimandresa...@gmail.com wrote: Ive been trying to get a listview working within a fragment all day. I dont know why but for some reason the way Im trying to do it, it just never wants to inflate the view. Im using actionbarsherlock if that makes a difference but I dont think so. Heres the class where my layout fails: public class GraffSearch extends FragmentActivity implements ActionBar.TabListener{ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.searchlayout);//-fails here final ActionBar ab = getSupportActionBar(); for (int i = 1; i 4; i++) { ab.addTab(ab.newTab().setText(Tab + i).setTabListener(this)); } ab.show(); if (ab.getNavigationMode() != ActionBar.NAVIGATION_MODE_TABS) { ab.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); } } @Override public void onTabReselected(Tab tab, FragmentTransaction ft) { // TODO Auto-generated method stub } @Override public void onTabSelected(Tab tab, FragmentTransaction ft) { //Toast.makeText(this, tabs work +tab.getPosition()+ user id is +avrid, Toast.LENGTH_LONG).show(); SearchListFrag fragment = (SearchListFrag) getSupportFragmentManager().findFragmentById(R.id.searchfrag); //fragment.updateUrl(tab.getPosition(), avrid); } @Override public void onTabUnselected(Tab tab, FragmentTransaction ft) { // TODO Auto-generated method stub } } and heres the layout were I call my fragment. ?xml version=1.0 encoding=utf-8? LinearLayout xmlns:android= http://schemas.android.com/apk/res/android; android:layout_width=match_parent android:layout_height=match_parent android:orientation=vertical ListFragment android:id=@+id/searchfrag android:layout_width=0dip android:layout_height=match_parent android:name=graffit.main.SearchListFrag android:layout_weight=1/ListFragment /LinearLayout Ive tried a few different setups going back and forth from using a regular fragment and a listfragment with the same result. Heres the logcat. 03-18 03:38:49.363: E/AndroidRuntime(8385): FATAL EXCEPTION: main 03-18 03:38:49.363: E/AndroidRuntime(8385): java.lang.RuntimeException: Unable to start activity ComponentInfo{graffit.main/graffit.main.GraffSearch}: android.view.InflateException: Binary XML file line #9: Error inflating class ListFragment 03-18 03:38:49.363: E/AndroidRuntime(8385): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1696) 03-18 03:38:49.363: E/AndroidRuntime(8385): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1716) 03-18 03:38:49.363: E/AndroidRuntime(8385): at android.app.ActivityThread.access$1500(ActivityThread.java:124) 03-18 03:38:49.363: E/AndroidRuntime(8385): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:968) 03-18 03:38:49.363: E/AndroidRuntime(8385): at android.os.Handler.dispatchMessage(Handler.java:99) 03-18 03:38:49.363: E/AndroidRuntime(8385): at android.os.Looper.loop(Looper.java:130) 03-18 03:38:49.363: E/AndroidRuntime(8385): at android.app.ActivityThread.main(ActivityThread.java:3806) 03-18 03:38:49.363: E/AndroidRuntime(8385): at java.lang.reflect.Method.invokeNative(Native Method) 03-18 03:38:49.363: E/AndroidRuntime(8385): at java.lang.reflect.Method.invoke(Method.java:507) 03-18 03:38:49.363: E/AndroidRuntime(8385): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) 03-18 03:38:49.363: E/AndroidRuntime(8385): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) 03-18 03:38:49.363: E/AndroidRuntime(8385): at dalvik.system.NativeStart.main(Native Method) 03-18 03:38:49.363: E/AndroidRuntime(8385): Caused by: android.view.InflateException: Binary XML file line #9: Error inflating class ListFragment 03-18 03:38:49.363: E/AndroidRuntime(8385): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:581) 03-18 03:38:49.363: E/AndroidRuntime(8385): at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)