Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #3218

Re: Initializing from context passing

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail
From Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid>
Newsgroups comp.lang.java.programmer
Subject Re: Initializing from context passing
Date Sat, 23 Apr 2011 18:35:07 +0200
Organization A noiseless patient Spider
Lines 51
Message-ID <iouv3r$5ls$1@dont-email.me> (permalink)
References <91ga4tF38vU1@mid.individual.net>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
Injection-Date Sat, 23 Apr 2011 16:35:07 +0000 (UTC)
Injection-Info mx03.eternal-september.org; posting-host="6N2JWx0xbmJaEsUXHWqNHA"; logging-data="5820"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18YInlUS8/1YcP1K1bmgs9T"
User-Agent Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9
In-Reply-To <91ga4tF38vU1@mid.individual.net>
Cancel-Lock sha1:mLrRf1Kh6IM0iydZgEXSbcHagLs=
Xref x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:3218

Show key headers only | View raw


On 23/04/2011 17:39, Dirk Bruere at NeoPax allegedly wrote:
> I have a Data class of the form:
>
> Data
> (
> public static ListView albumsLV;
> public static ArrayAdapter<String> albumsTitleAdapter
> public static ArrayList<String> albumsTitleArrayList = new
> ArrayList<String>();
>
> Data(Context ctx)
> {
> albumsLV = (ListView )((Activity) ctx).findViewById(R.id.ListViewAlbums);
>
> albumsTitleAdapter = new ArrayAdapter<String>(ctx,
> android.R.layout.simple_expandable_list_item_1,albumsTitleArrayList);
> }
>
> }
>
> and in the main method{
>
> public void onCreate(Bundle savedInstanceState)
> {
> super.onCreate(savedInstanceState);
> setContentView(R.layout.main);
> Context currentContext = this;
>
> Data data = new Data(currentContext);
>
> }
>
> lvAlbum = (ListView)findViewById(R.id.ListViewAlbums);
> lvAlbum.setAdapter(Data.albumsTitleAdapter);
> }
>
> I never use Data data variable again.
> Is that sufficient to initialize the static parameters in Data class?
>

Yeah, but it's crap. At least make it a static method e.g.
Data.init(Context).

And do use interface types rather than implementations, unless you
specifically rely on a detail of the implementation (which is often a
bad sign). That is, make it a List<T>, not an ArrayList<T>.

-- 
DF.
An escaped convict once said to me:
"Alcatraz is the place to be"

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Initializing from context passing Dirk Bruere at NeoPax <dirk.bruere@gmail.com> - 2011-04-23 16:39 +0100
  Re: Initializing from context passing Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2011-04-23 18:35 +0200
    Re: Initializing from context passing Dirk Bruere at NeoPax <dirk.bruere@gmail.com> - 2011-04-23 19:12 +0100
      Re: Initializing from context passing Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2011-04-23 21:47 +0200
    Re: Initializing from context passing Dirk Bruere at NeoPax <dirk.bruere@gmail.com> - 2011-04-23 20:34 +0100
      Re: Initializing from context passing Lew <noone@lewscanon.com> - 2011-04-23 18:35 -0400
        Re: Initializing from context passing Dirk Bruere at NeoPax <dirk.bruere@gmail.com> - 2011-04-24 01:17 +0100
          Re: Initializing from context passing Lew <noone@lewscanon.com> - 2011-04-23 20:32 -0400

csiph-web