Hi all,

I want to add a full layout on click of button, i did in below way...

I want when i press the R.id.phone_more_botton button, then entire
<LinearLayout android:id="@+id/add_contact_phone" (button + EditText)
will added, if i click again again add then entire layout.




addContact.java code....

if(view.getId()==R.id.phone_more_botton)
                {
                        LinearLayout addContactPhone;
        
addContactPhone=(LinearLayout)findViewById(R.id.add_contact_phone);  //
line 62
                        LinearLayout
ll=(LinearLayout)findViewById(R.id.add_contact_phone1);
                        addContactPhone.addView(ll);

                }


xml code---

--
-- some other Linear layout...
           <Button
                                                        
android:id="@+id/phone_more_botton"
                                                        
android:layout_width="20dip"
                                                        
android:layout_height="30dip"
                                                        android:clickable="true"
                                                        
android:onClick="moreButtonHandler"
                                                        
android:background="@drawable/ic_btn_round_plus"/>
--
--

<LinearLayout android:id="@+id/add_contact_phone"
                                        android:orientation="horizontal"
                                        android:layout_width="wrap_content"
                                        android:layout_height="wrap_content" >

                                   <Button
                                                
android:id="@+id/add_contact_phone_home"
                                                
android:layout_width="wrap_content"
                                                
android:layout_height="wrap_content"
                                                android:text="Home"/>

                                        <EditText 
android:id="@+id/edit_text_phone"
                                    
xmlns:android="http://schemas.android.com/apk/res/android";
                                    android:layout_width="match_parent"
                                    android:layout_height="wrap_content"
                                    android:phoneNumber="true"
                                    android:gravity="right"
                                    android:hint="Phone"/>

                           </LinearLayout>

error i'm getting....
11-12 15:39:10.491: WARN/dalvikvm(1274): threadid=1: thread exiting
with uncaught exception (group=0x4001d800)
11-12 15:39:10.501: ERROR/AndroidRuntime(1274): FATAL EXCEPTION: main
11-12 15:39:10.501: ERROR/AndroidRuntime(1274):
java.lang.IllegalStateException: Could not execute method of the
activity
11-12 15:39:10.501: ERROR/AndroidRuntime(1274):     at
android.view.View$1.onClick(View.java:2072)
11-12 15:39:10.501: ERROR/AndroidRuntime(1274):     at
android.view.View.performClick(View.java:2408)
11-12 15:39:10.501: ERROR/AndroidRuntime(1274):     at
android.view.View$PerformClick.run(View.java:8816)
11-12 15:39:10.501: ERROR/AndroidRuntime(1274):     at
android.os.Handler.handleCallback(Handler.java:587)
11-12 15:39:10.501: ERROR/AndroidRuntime(1274):     at
android.os.Handler.dispatchMessage(Handler.java:92)
11-12 15:39:10.501: ERROR/AndroidRuntime(1274):     at
android.os.Looper.loop(Looper.java:123)
11-12 15:39:10.501: ERROR/AndroidRuntime(1274):     at
android.app.ActivityThread.main(ActivityThread.java:4627)
11-12 15:39:10.501: ERROR/AndroidRuntime(1274):     at
java.lang.reflect.Method.invokeNative(Native Method)
11-12 15:39:10.501: ERROR/AndroidRuntime(1274):     at
java.lang.reflect.Method.invoke(Method.java:521)
11-12 15:39:10.501: ERROR/AndroidRuntime(1274):     at
com.android.internal.os.ZygoteInit
$MethodAndArgsCaller.run(ZygoteInit.java:868)
11-12 15:39:10.501: ERROR/AndroidRuntime(1274):     at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
11-12 15:39:10.501: ERROR/AndroidRuntime(1274):     at
dalvik.system.NativeStart.main(Native Method)
11-12 15:39:10.501: ERROR/AndroidRuntime(1274): Caused by:
java.lang.reflect.InvocationTargetException
11-12 15:39:10.501: ERROR/AndroidRuntime(1274):     at
com.sybase.mo.mail.AddContacts.moreButtonHandler(AddContacts.java:62)
11-12 15:39:10.501: ERROR/AndroidRuntime(1274):     at
java.lang.reflect.Method.invokeNative(Native Method)
11-12 15:39:10.501: ERROR/AndroidRuntime(1274):     at
java.lang.reflect.Method.invoke(Method.java:521)
11-12 15:39:10.501: ERROR/AndroidRuntime(1274):     at
android.view.View$1.onClick(View.java:2067)
11-12 15:39:10.501: ERROR/AndroidRuntime(1274):     ... 11 more
11-12 15:39:10.501: ERROR/AndroidRuntime(1274): Caused by:
java.lang.NullPointerException
11-12 15:39:10.501: ERROR/AndroidRuntime(1274):     at
android.view.ViewGroup.addView(ViewGroup.java:1815)
11-12 15:39:10.501: ERROR/AndroidRuntime(1274):     at
android.view.ViewGroup.addView(ViewGroup.java:1802)
11-12 15:39:10.501: ERROR/AndroidRuntime(1274):     ... 15 more
11-12 15:39:10.520: WARN/ActivityManager(60):   Force finishing
activity com.sybase.mo/.mail.AddContacts

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to