Friday 15 February 2013

android - How to add an adapter to a listView? -


I have the following code to add a custom adapter to a ListView but it gives the following error on the line where I set adapter:

android.content.res.Resources $ NotFoundException: string resource ID # 0x68

  public class PackageListFragment piece extension (Packejadaptr Packejitm Adapter ; ArrayList & LT; PackageClass & gt; list; package Class package list; Tekstdrishy main lines; @Override public view onCreateView (LayoutIn Flater Inflater, ViewGroup container, bundle savedInstanceState) {See rootView = inflater.inflate (R.layout.activity_aps__main, container, false); ListView lv = (ListView) rootView.findViewById (R.id.packageList); {List = getAllPackages ( Try); PackageItemAdapter = new PackageAdapter (getActivity (). GetApplicationContext (), 0, list); lv.setAdapter (packageItemAdapter);}} catch (exception ex) {Log.e ( "listItem", ex.toString ( ));} Return Root View;} Public Array List & lt; Package class & gt; GetAllPackages () throws Exception {New DBFunctions return (getActivity (). GetApplicationContext ()). Recover AllPackage (); }}   

What am I doing wrong? My application stops without start: (

After your question editing, I have my brackets in a notice of is trying / hold block wrong. I answer the question in your copy the code and potential attacker bracket comment. but it's just questions and No, your code may be a mistake, since I do not believe it will be compiled with this problem.

  public view onCreateView (LayoutInflater inflater, ViewGroup container, bundle savedInstanceState) {See rootView = inflater.inflate (R.layout.activity_aps__main, container, false); ListView lv = (ListView) rootView.findViewById (R.id.packageList) ; try {list = getAllPackages (); packageItemAdapter = new PackageAdapter (getActivity (). getApplicationContext (), 0, list); lv. SetAdapter (packageItemAdapter);}} // & lt; ---- hold space (exception ex ) to find out {Log.e ( "listItem", ex.toString ());} return rootView;}    

No comments:

Post a Comment