hello Ratheesh, Thanks a lot for your reply. I tried the code that you sent me, but now too am getting the same 'Force close' error. It shows 'The application has stopped unexpectedly. Please try again'.
I tried this application in Debug perspective, while debugging it shows 'Source not found- Edit source lookup path'. Though I edit the source attachment for a jar file, it is not updated, it shows the same state as 'source attachment (None)'. Please help me to execute the application without errors. The errors and information in the LogCat are 08-06 10:34:15.169: ERROR/DEBUGTAG(220): error occured 08-06 10:34:15.169: ERROR/DEBUGTAG(220): java.lang.Exception 08-06 10:34:15.169: ERROR/DEBUGTAG(220): at hello.tab.HelloUIActivity.<init>(HelloUIActivity.java:44) 08-06 10:34:15.169: ERROR/DEBUGTAG(220): at java.lang.Class.newInstanceImpl(Native Method) 08-06 10:34:15.169: ERROR/DEBUGTAG(220): at java.lang.Class.newInstance(Class.java:1479) 08-06 10:34:15.169: ERROR/DEBUGTAG(220): at android.app.Instrumentation.newActivity(Instrumentation.java:1021) 08-06 10:34:15.169: ERROR/DEBUGTAG(220): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java: 2409) 08-06 10:34:15.169: ERROR/DEBUGTAG(220): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java: 2512) 08-06 10:34:15.169: ERROR/DEBUGTAG(220): at android.app.ActivityThread.access$2200(ActivityThread.java:119) 08-06 10:34:15.169: ERROR/DEBUGTAG(220): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863) 08-06 10:34:15.169: ERROR/DEBUGTAG(220): at android.os.Handler.dispatchMessage(Handler.java:99) 08-06 10:34:15.169: ERROR/DEBUGTAG(220): at android.os.Looper.loop(Looper.java:123) 08-06 10:34:15.169: ERROR/DEBUGTAG(220): at android.app.ActivityThread.main(ActivityThread.java:4363) 08-06 10:34:15.169: ERROR/DEBUGTAG(220): at java.lang.reflect.Method.invokeNative(Native Method) 08-06 10:34:15.169: ERROR/DEBUGTAG(220): at java.lang.reflect.Method.invoke(Method.java:521) 08-06 10:34:15.169: ERROR/DEBUGTAG(220): at com.android.internal.os.ZygoteInit $MethodAndArgsCaller.run(ZygoteInit.java:860) 08-06 10:34:15.169: ERROR/DEBUGTAG(220): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) 08-06 10:34:15.169: ERROR/DEBUGTAG(220): at dalvik.system.NativeStart.main(Native Method) 08-06 10:34:15.188: INFO/UserInterface(220): UILogCat 08-06 10:34:15.188: INFO/UserInterface(220): java.lang.Exception 08-06 10:34:15.188: INFO/UserInterface(220): at hello.tab.HelloUIActivity.<init>(HelloUIActivity.java:44) 08-06 10:34:15.188: INFO/UserInterface(220): at java.lang.Class.newInstanceImpl(Native Method) 08-06 10:34:15.188: INFO/UserInterface(220): at java.lang.Class.newInstance(Class.java:1479) 08-06 10:34:15.188: INFO/UserInterface(220): at android.app.Instrumentation.newActivity(Instrumentation.java:1021) 08-06 10:34:15.188: INFO/UserInterface(220): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java: 2409) 08-06 10:34:15.188: INFO/UserInterface(220): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java: 2512) 08-06 10:34:15.188: INFO/UserInterface(220): at android.app.ActivityThread.access$2200(ActivityThread.java:119) 08-06 10:34:15.188: INFO/UserInterface(220): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863) 08-06 10:34:15.188: INFO/UserInterface(220): at android.os.Handler.dispatchMessage(Handler.java:99) 08-06 10:34:15.188: INFO/UserInterface(220): at android.os.Looper.loop(Looper.java:123) 08-06 10:34:15.188: INFO/UserInterface(220): at android.app.ActivityThread.main(ActivityThread.java:4363) 08-06 10:34:15.188: INFO/UserInterface(220): at java.lang.reflect.Method.invokeNative(Native Method) 08-06 10:34:15.188: INFO/UserInterface(220): at java.lang.reflect.Method.invoke(Method.java:521) 08-06 10:34:15.188: INFO/UserInterface(220): at com.android.internal.os.ZygoteInit $MethodAndArgsCaller.run(ZygoteInit.java:860) 08-06 10:34:15.188: INFO/UserInterface(220): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) 08-06 10:34:15.188: INFO/UserInterface(220): at dalvik.system.NativeStart.main(Native Method) Thank you, Divya On Aug 5, 6:24 pm, Ratheesh Valamchuzhy <[email protected]> wrote: > hi Divya > > First the problem is > > You using the same id to both image view and button so it displays the " > force to close erro" > > the correct code is here > > package lello.tab; > import android.app.Activity; > import android.os.Bundle; > import android.util.Log; > import android.view.View; > import android.view.View.OnClickListener; > import android.widget.Button; > import android.widget.ImageView; > import android.widget.Toast; > public class HelloUIActivity extends Activity implements OnClickListener{ > > /** Called when the activity is first created. */ > @Override > public void onCreate(Bundle savedInstanceState) { > super.onCreate(savedInstanceState); > setContentView(R.layout.main); > > Button sSquare =(Button) findViewById(R.id.getCircle); > sSquare.setOnClickListener(this); > Button sCircle =(Button) findViewById(R.id.getSquare); > sCircle.setOnClickListener(this); > > } > > public void onClick(View v) > { > switch (v.getId()) { > case R.id.getSquare: > ImageView imageView = (ImageView) > findViewById(R.id.getSquare1); > imageView.setImageResource(R.drawable.icon); > > break; > > case R.id.getCircle: > ImageView imageView1 = (ImageView) > findViewById(R.id.getCircle1); > imageView1.setImageResource(R.drawable.icon); > break; > } > > } > } > > thanks ....... -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

