rcorbellini
rcorbellini

Reputation: 1337

suggestion to my structure activitys (Android)

I have many common code in onCreate/onPause etc...

I created a CommonActivity that extend Activity and mines activity extend that (oooh fine all work now)

but... now I need a ListActivity (with setListAdapter) and all common code of CommonActivity

(obs i use Sherlock action bar, I don't extend directly Activity/ListActivity) show my problem:

Problem with sctructure (sorry by paint mode on!)

how can I do that?

EDITED: I need ListView to use that (I don't know other way):

ArrayAdapter<MyBean> adapter = new ArrayAdapter<MyBean>(this,    android.R.layout.simple_list_item_1, values);
setListAdapter(adapter);

Upvotes: 2

Views: 58

Answers (1)

class stacker
class stacker

Reputation: 5347

You don't need a ListActivity to use the following code snippet:

ArrayAdapter<MyBean> adapter = new ArrayAdapter<MyBean>(this, android.R.layout.simple_list_item_1, values);
setListAdapter(adapter);

With a minor modification, the same commands are valid for a ListView object, as I already pointed out, see here:

ArrayAdapter<MyBean> adapter = new ArrayAdapter<MyBean>(this, android.R.layout.simple_list_item_1, values);
setAdapter(adapter);

Upvotes: 1

Related Questions