atom feed1 message in com.googlegroups.android-beginnersRe: [android-beginners] problem addin...
FromSent OnAttachments
Megha JoshiFeb 28, 2008 2:49 pm 
Subject:Re: [android-beginners] problem adding view items
From:Megha Joshi (mjo@google.com)
Date:Feb 28, 2008 2:49:46 pm
List:com.googlegroups.android-beginners

Hi Sateesh,

You could use the addView() method to add views to your LinearLayout. The code you provided is incomplete(I dont know what "this" is in *this* .addContentView ) but it seems you are not adding views to a layoutmanager. I tweaked your code to show an example of adding views to a layoutmanager.

TextView tx; @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.main); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT,

LinearLayout.LayoutParams.WRAP_CONTENT); LinearLayout lx = (LinearLayout)findViewById(R.id.layout); for (int i =0; i < 3; i++) {

tx = new TextView(this); tx.setText("text"); lx.addView(tx,layoutParams); }

}

Thanks, Megha

On Wed, Feb 27, 2008 at 11:25 PM, Sateesh Devabhaktuni < Sate@interrait.com> wrote:

Hi,

I added a custom item into a vector then at the time of display I fetched it from vector and trying to add into view for display but by using addView(…); am not able to add it. It became possible by using this.addContentView(…); but now successfully items placed onto the screen are overlapping even though I am using Linear Layout for display and set orientation as vertical.

I would appreciate the suggestions if you can either tell how can I add my view using addView(…) or can display by using this.addContentView(…)

setContentView(R.layout.*formfactory_layout* );

layoutParams = *new* LinearLayout.LayoutParams(LinearLayout.LayoutParams.*FILL_PARENT*,

LinearLayout.LayoutParams.* WRAP_CONTENT*);

//ViewGroup vgroup = new ViewGroup(this) ;

*int* field_len = formFac.fieldVector .size();

*for* (*int* i = 0; i < field_len; i++) {

*if* (formFac.readonlyVector .elementAt(i).equals("")){

*this*.addContentView((View) formFac.fieldVector.elementAt(i), layoutParams);

}*catch* (NullPointerException nex){

Log.*i*(tag,
"NullPointerException :" +nex.toString());

Log.*i*(tag,
"NullPointerException1 :" +nex.getCause());

}

}

}

Regards,

sateeshd