Friday, October 29, 2010

[android-developers] to call only a single activity on different button clicks

i have three imagebuttons.and on clicking each buttons a new image
with new screen opens.means three imagebuttons calls three different
activities.
it means if you have ten buttons we have to call 10 activities.
i want to call the common activity on each button clicked using if
else construct


switch (v.getId()) {
case R.id.btnSequence:
Intent intent1 = new Intent();
intent1.setClass(this,Activity1.class);
startActivity(intent1);
break;

case R.id.btnVideo:
Intent intent2 = new Intent();

intent2 .setClass(this,Activity2.class);
startActivity(intent2);
break;

case R.id.btnInfo:
Intent intent3 = new Intent();

intent3 .setClass(this,Activity3.class);
startActivity(intent3);
break;
}

is there any way to call the different instance of common activity(say
CommonActivity.class) for all three buttons.

--
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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate