From: Dirk Bruere at NeoPax Newsgroups: comp.lang.java.programmer Subject: Re: ArrayAdapter Date: Fri, 01 Apr 2011 00:42:50 +0100 Organization: Dirk Bruere at Neopax Lines: 87 Message-ID: <8vkhrlFvkjU1@mid.individual.net> References: <8vi26oFvh2U1@mid.individual.net> <8vj6efFla6U1@mid.individual.net> <8vjevuFn7mU1@mid.individual.net> <8vjhisFai4U1@mid.individual.net> <8vji5pFfcsU1@mid.individual.net> <8vjl9tFa13U1@mid.individual.net> <8vk6c8Fe5gU1@mid.individual.net> <8vk6gcFe5gU2@mid.individual.net> Reply-To: dirk.bruere@gmail.com Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net IubG9OHOfKzcqLfqtyjsGw3eCL8BFpfwgE/63jlxPfAz/7iaur Cancel-Lock: sha1:TOCiU2px8vGTc9X6yda9uw6DzEM= User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9 In-Reply-To: Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.stben.net!border3.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!border4.nntp.ams.giganews.com!border2.nntp.ams.giganews.com!nntp.giganews.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:2673 On 31/03/2011 23:27, markspace wrote: > On 3/31/2011 1:50 PM, Patricia Shanahan wrote: > >> Either you have serious problems with program structure that would >> prevent compilation or you have problems pasting code into articles. > > I'm guessing this time it's the latter. > > >> > >> This code crashes out > > This didn't end with a period which is uncharacteristic for the OP. I > think his newsreader just failed, is all. > > > To the OP: bits like these below: > > >> ...//Get titleStr etc > > >> lvRadio = (ListView)findViewById(R.id.ListViewRadio); > >> } > >> ... > > won't ever compile. Please remove the ...'s and post code that does > compile, or at least shows what error with the compiler you are actually > having. > Those dots are just all the other methods and code to generate titleStr. The code I have just posted loads the title strings into the ArrayAdapter OK. The problem occurs HERE public class controller extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Context currentContext = this; final BlinkAPI blinkAPI = new BlinkAPI(currentContext); ListView lvRadio = (ListView)findViewById(R.id.ListViewRadio); } ... } //Everything below is in a separate file public class BlinkAPI { private static Context mContext; static ListView radioLV; static ArrayList radioTitleArrayList = new ArrayList(); public BlinkAPI( Context ctx) { BlinkAPI.mContext = ctx; radioLV = (ListView )((Activity) mContext).findViewById(R.id.ListViewRadio); } private static void updateRadioTitles( ) { ArrayAdapter radioTitleAdapter = new ArrayAdapter(mContext, android.R.layout.simple_expandable_list_item_1,radioTitleArrayList); String titleStr="hello"; radioTitleAdapter.add(titleStr); radioLV.setAdapter(radioTitleAdapter); //HERE - the debugger splashes up "source not found" radioTitleAdapter.notifyDataSetChanged(); } } -- Dirk http://www.neopax.com/technomage/ - My new book - Magick and Technology