Re: ArrayAdapter
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<String> radioTitleArrayList = new ArrayList<String>();
public BlinkAPI( Context ctx)
{
BlinkAPI.mContext = ctx;
radioLV = (ListView )((Activity)
mContext).findViewById(R.id.ListViewRadio);
}
private static void updateRadioTitles( )
{
ArrayAdapter<String> radioTitleAdapter = new
ArrayAdapter<String>(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