ListView in custom preference

by Eric Crump » Wed, 19 Jan 2011 11:01:59 GMT


Sponsored Links
 I need to put a ListView in a custom preference.  It needs to look
similiar to the WiFi settings in the OS preferences.  My problem is I
am unable to make it take fill the space.  It only takes up the space
given to a normal preferece item.  How do I make the LinearLayout I
return from onCreateView take up the remainder of the height?

@Override
protected View onCreateView(ViewGroup parent){

        LinearLayout layout = new LinearLayout(getContext());

        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.FILL_PARENT,LinearLayout.LayoutParams.FILL_PARENT);

        layout.setOrientation(LinearLayout.VERTICAL);

        list = new ListView(getContext());
        list.setLayoutParams(params);

        layout.addView(list);
        layout.setBackgroundColor(Color.GREEN);

        adapter = new ArrayAdapter<String>(getContext(),
android.R.layout.simple_list_item_1, new String[]{"abc", "def"});
        list.setAdapter(adapter);

        return layout;
}

Sorry for a repost.  My original post seems to have disappeared.

-- 



Re: ListView in custom preference

by kavitha b » Thu, 20 Jan 2011 04:40:12 GMT


 Use Custom List View Item extending Base Adapter





-- 


Sponsored Links


Other Threads

1. X10 Interface

Bros,

Besok X10 launch di Spore, tadi lihat interface timescape dan mediascape
nya. amazing.
Kapan ya ada rom X10 untuk N1? *ngimpi*

sekarang cukup puas dengan desire rom dulu deh.

Andreas

-- 
"Indonesian Android Community [id-android]" 

2. SlideScreen

Guys....

Kalo ada yg punya, tp yg Pro :) , japri dong :D

Thx yah

--
Jus* ^ owner white dream ^
~ send using pc jangkrik krik krik ~
$ www.cash-flowing.com $

--
"Indonesian Android Community [id-android]"

3. Parent View intercepts events on Child View

4. i-Mobile IE 6010

5. FYI : Astro update

6. Pejing AJ

7. Calander