Sunday 15 April 2012

java - dynamically adding views in a particular position -



java - dynamically adding views in a particular position -

i adding dynamically views on button click.in views there imageview.after clicking on imageview adding photos gallery.it's working till now.now problem photo set in wrong position.it means adding @ lastly view .how can solved.thanks in advance.

buttonadd.setonclicklistener(new onclicklistener() { @override public void onclick(view arg0) { layoutinflater layoutinflater = (layoutinflater) getbasecontext().getsystemservice(context.layout_inflater_service); addview = layoutinflater.inflate(r.layout.add, null); edittext textout = (edittext) addview.findviewbyid(r.id.text); // textout.settext(textin.gettext().tostring()); img = (imageview) addview.findviewbyid(r.id.takephoto); img.setonclicklistener(new onclicklistener() { @override public void onclick(view v) { img.setimagebitmap(photo); } }); } });

here add.xml

<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <linearlayout android:id="@+id/l1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_margintop="20dp" android:weightsum="2"> <imageview android:id="@+id/takephoto" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginleft="20dp" android:layout_weight=".75" android:src="@drawable/ic" /> <edittext android:id="@+id/text" android:layout_width="0dp" android:imeoptions="actionnext" android:singleline="true" android:background="#0000" android:hint="enter option" android:layout_height="wrap_content" android:layout_weight="1" android:maxlength="40" /> </linearlayout> </relativelayout>

java android

No comments:

Post a Comment