Set dynamically created TextView on frame layout - android

I want to pass some data from one activity to another and set it in dynamically created TextView over frame layout of that activity..I'm using intent for that but at second activity the data is not getting extracted..Can any one tell me the simple way for this..
Following is my code..
Hidden.java
public class Hidden extends Activity implements OnClickListener {
Button btnnameadd, btnnameremove, btnmobileadd, btnmobileremove, btndone;
EditText etname, etmobile;
ImageView ivlogo;
private AlertDialog dialog;
private Uri mImageCaptureUri;
Intent jump;
//options for image selection
private static final int PICK_FROM_CAMERA = 1;
private static final int CROP_FROM_CAMERA = 2;
private static final int PICK_FROM_FILE = 3;
LinearLayout llname, llmobile, llimage;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.hidden);
captureImageInitialization();
init();
}
private void init() {
etname=(EditText)findViewById(R.id.editTextname);
etmobile=(EditText)findViewById(R.id.editTextmobile);
btnnameadd=(Button)findViewById(R.id.buttonnameadd);
btnnameremove=(Button)findViewById(R.id.buttonnameremove);
btnmobileadd=(Button)findViewById(R.id.buttonmobileadd);
btnmobileremove=(Button)findViewById(R.id.buttonmobileremove);
btndone=(Button)findViewById(R.id.buttondone);
llname=(LinearLayout)findViewById(R.id.name);
llmobile=(LinearLayout)findViewById(R.id.mobile);
btnnameadd.setOnClickListener(this);
btnnameadd.setOnClickListener(this);
btnnameremove.setOnClickListener(this);
btnmobileadd.setOnClickListener(this);
btnmobileremove.setOnClickListener(this);
btndone.setOnClickListener(this);
}
#Override
public void onClick(View v) {
jump=new Intent(Hidden.this,Framelayout.class);
if(v.getId()==R.id.buttonnameadd)
{
String strname=etname.getText().toString();
Log.d("Log",strname);
jump.putExtra("Name",strname);
}else if(v.getId()==R.id.buttonnameremove)
{
btnnameremove.setEnabled(false);
llname.removeView(findViewById(R.id.editTextname));
}else if(v.getId()==R.id.buttonmobileadd)
{
String strmobile=etmobile.getText().toString();
Log.d("Log",strmobile);
jump.putExtra("Mobile",strmobile);
Log.d("LOG",jump.putExtra("Mobile",strmobile).toString());
}else if(v.getId()==R.id.buttonmobileremove)
{
llmobile.removeView(findViewById(R.id.editTextmobile));
}else if(v.getId()==R.id.buttondone)
{
Log.d("LOG","1");
startActivity(jump);
}
}
}
FrameLayout.java
public class Framelayout extends Activity implements OnClickListener {
FrameLayout frameLayout;
Button b2,b3;
//private ProgressDialog pDialog;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_framelayout);
frameLayout = (FrameLayout)findViewById(R.id.f1);
b2=(Button)findViewById(R.id.button2);
b3=(Button)findViewById(R.id.buttonload);
b2.setOnClickListener(this);
b3.setOnClickListener(this);
}
public void onClick(View v) {
if(v.getId()==R.id.button2){
Intent i=new Intent(Framelayout.this,Hidden.class);
startActivity(i);
}else if(v.getId()==R.id.buttonload){
Log.d("Log",getIntent().getStringExtra("Name"));
editframelayout();
}
}
private void editframelayout() {
String name=getIntent().getExtras().getString("Name");
String mobile=getIntent().getExtras().getString("Mobile");
TextView tvname=new TextView(this);
tvname.setText(name);
tvname.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
tvname.setGravity(Gravity.CENTER);
TextView tvmobile=new TextView(this);
tvmobile.setText(mobile);
tvmobile.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
tvmobile.setGravity(Gravity.CENTER);
frameLayout.addView(tvname);
frameLayout.addView(tvmobile);
}
}

You must use one of putExtra() overloaded methods of the intent instance you created to add your data.
Here is a sample:
Intent intent = new Intent(this, SignoutActivity.class); // # this parameter is the context of the caller
intent.putExtra("PARAM_TEXTBOX_TEXT", textboxText);
startActivity(intent);
Edit for the code you added, your design is very poor and doesn't accomplish what is intended.
Every time you click a Button a new instance of Intent is created. you are calling startActivity() only in single case:
else if(v.getId()==R.id.buttondone)
{
Log.d("LOG","1");
startActivity(jump);
}
Now you assume that the parameters added in previous button clicks are still there, but they aren't. When you click buttondone you create a new instance of Intent with no extras at all.
You can work this around as follows:
...
else if(v.getId()==R.id.buttondone)
{
String strname = etname.getText().toString();
if (strname != null && !strname.equals(""))
{
jump.putExtra("Name",strname);
}
String strmobile = etmobile.getText().toString();
if (strmobile != null && !strmobile.equals(""))
{
jump.putExtra("Mobile",strmobile);
}
startActivity(jump);
}
It still isn't well structured, but might do the trick for you

Use getIntent().getStringExtra("Name") instead of getIntent().getExtras().getString("Name");
getIntent().getStringExtra("Name")

Related

Passing multicheckbox values to another activity

Let me try this again with better phrasing. I am very new at this; I am trying to pass the value result of checkbox’s to another activity. I have tried it a few different ways without success and I would be grateful for some direction.
I know how to make a “Toast” with the result, that is not what I want it to do. I want the checkbox results will appear in a textview in another activity. If someone could help me out with some hints on how to accomplish that task I would be grateful, I am sorry to bother everyone with such unchallenging questions.
I have read a couple books and watched some tutorials but my skills are still lacking. The books are as repetitive and redundant as the tutorials (buttons and layouts, etc.).
final CheckBox chbxshirleys = (CheckBox)findViewById(R.id.checkboxshirleys);
final CheckBox chbxdianas = (CheckBox)findViewById(R.id.checkboxdianas);
final CheckBox chbxzoila = (CheckBox)findViewById(R.id.checkboxzoila);
final CheckBox chbxsheila = (CheckBox)findViewById(R.id.checkBoxSheila);
final CheckBox chbxrobert = (CheckBox)findViewById(R.id.checkBoxrobert);
final CheckBox chbxsam = (CheckBox)findViewById(R.id.checkBoxsam);
final CheckBox chbxcamren = (CheckBox)findViewById(R.id.checkBoxcamren);
final CheckBox chbxricks = (CheckBox)findViewById(R.id.checkBoxricks);
final Button vendorbutton = (Button)findViewById(R.id.vendorbutton);
vendorbutton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
String vendor ="";
if (chbxshirleys.isChecked())
{
vendor += chbxshirleys.getText();
}
if (chbxdianas.isChecked())
{
vendor += chbxdianas.getText();
}
if (chbxzoila.isChecked())
{
vendor += chbxzoila.getText();
}
if (chbxsheila.isChecked())
{
vendor += chbxsheila.getText();
}
if (chbxrobert.isChecked())
{
vendor += chbxrobert.getText();
}
if (chbxsam.isChecked())
{
vendor += chbxsam.getText();
}
if (chbxcamren.isChecked())
{
vendor += chbxcamren.getText();
}
if (chbxricks.isChecked())
{
vendor += chbxricks.getText();
}
Intent myIntent=new Intent(getApplication(),ApplianceMessage.class);
myIntent.putExtra("chbxshirleys", vendor);
myIntent.putExtra("chbxdianas", vendor);
myIntent.putExtra("chbxzoila", vendor);
myIntent.putExtra("chbxsheila", vendor);
myIntent.putExtra("chbxrobert", vendor);
myIntent.putExtra("chbxsam", vendor);
myIntent.putExtra("chbxcamren", vendor);
myIntent.putExtra("chbxricks", vendor);
startActivity(myIntent);
}
});
}
new activity
public class ApplianceMessage extends Activity {
private TextView tvname = (TextView)findViewById(R.id.tvname);
private EditText etname = (EditText)findViewById(R.id.etname);
private TextView tvcity = (TextView)findViewById(R.id.tvcity);
private EditText etcity = (EditText)findViewById(R.id.etcity);
private TextView tvtime = (TextView)findViewById(R.id.tvtime);
private EditText ettime = (EditText)findViewById(R.id.ettime);
private RadioButton rbutton =(RadioButton)findViewById(R.id.rburgent);
private TextView tvproblem = (TextView)findViewById(R.id.rburgent);
private EditText etproblem = (EditText)findViewById(R.id.etproblem);
private TextView tvvendor = (TextView)findViewById(R.id.vendorlist);
private Button msendbutton;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.appliance_message);
final Bundle extras = getIntent().getExtras();
extras.getInt("chbxshirleys");
extras.getInt("chbxdianas");
extras.getInt("chbxzoila");
extras.getInt("chbxshiela");
extras.getInt("chbxrobert");
extras.getInt("chbxcamren");
extras.getInt("chbxsam");
extras.getInt("chbxricks");
msendbutton = (Button)findViewById(R.id.sendbutton);
msendbutton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
tvname.setText("Insert Name");
etname.setText("");
tvcity.setText("City Name");
etcity.setText("");
tvtime.setText("Time");
ettime.setText("");
tvproblem.setText("Problem");
etproblem.setText("");
}
});
}
}
In your first activity:
Intent i=new Intent(YourClassName.this,ApplianceMessage.class);
i.putExtra("selected",vendor);
startActivity(i);
In your second Activity:
String selecteditem=getIntent().getExtras().getString("selected");
textview.setText(selecteditem);
You're putting a String Extra in the intent. Just get it by:
getIntent().getStringExtra("chbxshirleys");
....

Confuse about android check list box

I would like to implement products list with checklistbox after select radio button.
And I would like to show chekclistbox as dialog box. My product list data come from sqllite.
It is need to implement adapter class to show data for checklistbox or can I directly implement for checklistbox data in alertDialog . Please clear for me.
In mainActivity
public RadioGroup.OnCheckedChangeListener setOnCheckedChangeListener = new OnCheckedChangeListener() {
#Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
rdoPCode = (RadioButton) findViewById(checkedId);
switch (checkedId) {
case R.id.rdoAll:
Toast.makeText(context, rdoPCode.getText(), Toast.LENGTH_SHORT)
.show();
break;
case R.id.rdoCustom:
Intent localIntent = new Intent(MainActivity.context,
ProductListChkActivity.class);
MainActivity.context.startActivity(localIntent);
break;
}
}
};
In ProductListChkActivity
public class ProductListChkActivity extends Activity {
private static Button button_selectall;
private static Button button_unselectall;
private static CheckBox chkProductCode;
private static CashSaleProductLogic _sellProductLogic;
public static List<CashSaleProductInfo> _SaleProductInfo;
public static ListView lvlchkPrdlist;
private Button btnSelectAll, btnUnSelectAll;
// For chk productcode
private static ProductListChkAdapter _ProductListChkAdapter;
Context context;
#Override
protected void onCreate(Bundle paramBundle) {
super.onCreate(paramBundle);
setContentView(R.layout.productinofchk);
context = this;
init();
ProductCodeChk();
}
private void init() {
button_selectall = (Button) this.findViewById(R.id.button_selectall);
button_unselectall = (Button) this
.findViewById(R.id.button_unselectall);
chkProductCode = (CheckBox) this.findViewById(R.id.chkProductCode);
lvlchkPrdlist = (ListView) this.findViewById(R.id.lvlchkPrdlist);
_sellProductLogic = new CashSaleProductLogic(this);
_SaleProductInfo = _sellProductLogic.getAllsellProductDataLogic();
}
protected void ProductCodeChk() {
try {
_ProductListChkAdapter = new ProductListChkAdapter(context,
_SaleProductInfo, 1);
this.lvlchkPrdlist.setAdapter(_ProductListChkAdapter);
} catch (Exception e) {
e.printStackTrace();
return;
}
}
public void OnClickbillbtncancel(View paramView) {
MainActivity.textClear();
Intent localIntent = new Intent(ProductListChkActivity.this,
MainActivity.class);
ProductListChkActivity.this.startActivity(localIntent);
}
}
I would like to show productinofchk layout as dialogbox
You need to go through floating dialogs in android. check out this documentation :
link

Refresh ListView with ArrayAdapter after editing an Item

I have a ListView, which displays a list of notes taken from a table in SQLiteDatabase with ArrayAdapter.
public class NotepadActivity extends ListActivity {
protected static final int ADD_NEW_NOTE = 0;
protected static final int EDIT_NOTE = 1;
ArrayAdapter<Note> adapter;
NotesManager manager;
private Note nNoteToDelete;
ArrayList<Note> lstAllNotes;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
findViewById(R.id.btnAddNewNote).setOnClickListener(addNewNote);
manager = new NotesManager(this);
lstAllNotes = manager.getAllNotes();
adapter = new ArrayAdapter<Note>(this, R.layout.note, lstAllNotes);
setListAdapter(adapter);
getListView().setOnItemClickListener(editNote);
registerForContextMenu(getListView());
}
When I click on an Item in this ListView, it takes this Note object to the EditNote activity:
private OnItemClickListener editNote = new OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View view, int position,
long id) {
Note currNote = (Note)parent.getItemAtPosition(position);
int curr_note_id = currNote.getId();
String curr_note_title = currNote.getTitle().toString();
String curr_note_details = currNote.getDetails().toString();
Intent editNote = new Intent(NotepadActivity.this, EditNote.class);
editNote.putExtra("CURR_NOTE_ID", curr_note_id);
editNote.putExtra("CURR_NOTE_TITLE", curr_note_title);
editNote.putExtra("CURR_NOTE_DETAILS", curr_note_details);
startActivityForResult(editNote, EDIT_NOTE);
}
};
I can edit the title of the note in there and the content. When I hit the Save button, it sends back to the main activity the Strings of Title and the Details and the ID int:
public class EditNote extends Activity implements OnClickListener {
int curr_note_id;
String curr_note_title;
String curr_note_details;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.editnote);
curr_note_id = getIntent().getExtras().getInt("CURR_NOTE_ID");
curr_note_title = getIntent().getExtras().getString("CURR_NOTE_TITLE");
curr_note_details = getIntent().getExtras().getString(
"CURR_NOTE_DETAILS");
((EditText) findViewById(R.id.edtTitle)).setText(curr_note_title);
((EditText) findViewById(R.id.edtDetails)).setText(curr_note_details);
findViewById(R.id.btnSave).setOnClickListener(this);
findViewById(R.id.btnCancel).setOnClickListener(this);
}
#Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.btnSave:
String strNoteTitle = ((EditText) findViewById(R.id.edtTitle)).getText().toString().trim();
String strNoteDetails = ((EditText) findViewById(R.id.edtDetails)).getText().toString().trim();
if (!strNoteTitle.equals("")) {
Intent data = new Intent();
data.putExtra("NOTE_ID", curr_note_id);
data.putExtra("NOTE_TITLE", strNoteTitle);
data.putExtra("NOTE_DETAILS", strNoteDetails);
setResult(RESULT_OK, data);
finish();
} else {
((EditText) findViewById(R.id.edtTitle))
.setError("A note must contain a title");
}
break;
case R.id.btnCancel:
setResult(RESULT_CANCELED);
finish();
break;
}
}
}
And in the main activity it should update the DB and the ListView with the new Title, if there were changes. My code does update the DB, but I don't see the change in the ListView immediately, only if I exit the app and open it again. Here's the code (watch the second case, EDIT_NOTE):
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_OK) {
switch (requestCode) {
case ADD_NEW_NOTE:
String noteTitle = data.getExtras().getString("NOTE_TITLE");
String noteDetails = data.getExtras().getString("NOTE_DETAILS");
Note nNewNote = new Note(-1, noteTitle, noteDetails);
adapter.add(nNewNote);
manager.addNote(nNewNote);
break;
case EDIT_NOTE:
int noteID = data.getExtras().getInt("NOTE_ID");
noteTitle = data.getExtras().getString("NOTE_TITLE");
noteDetails = data.getExtras().getString("NOTE_DETAILS");
nNewNote = new Note(noteID, noteTitle, noteDetails);
Toast.makeText(NotepadActivity.this, noteTitle + "\n" + noteDetails, Toast.LENGTH_SHORT).show();
manager.updateNote(nNewNote);
break;
}
}
super.onActivityResult(requestCode, resultCode, data);
}
After manager.updateNote(nNewNote); I tried to use adapter.notifyDataSetChanged(); but that didn't work - I didn't see the change in the ListView. Perhaps I used it wrong, perhaps I should use something else...
So how can I make the ListView refresh? How can I see change immediately, without restarting the app?
Thank you!
When you return from the edit activity, set the list adapter again to refresh the ListView. You have to manually refresh the ListView each time if you want to see any updates. Hope this helps.

Keep a view alive while switching activity

I created a game, where I rotate through multiple activitys. Each activity stays just for a few seconds. Now I should add ads to the game. Since it doesn't make sense if the ad refreshes after just a few seconds I have to create a view which stays alive the whole time even if I start a new activity.
Since a view is bind to an activity (?) it might not be possible. So I wonder wether there is another solution to keep the adView alive while the content views are rotating.
Thanks in advance.
Edit:
Here is a simple Activity which is part of the activity cycle:
public class Punish extends ActivityWithSound implements OnClickListener {
#SuppressWarnings("unused")
private final String TAG = "Punish";
private RelativeLayout buttonContainer;
private ImageView bgImg;
private TextView nameTxt;
private TextView questTxt;
private Button mainMenuBtn;
private Button okBtn;
private Bundle bundle;
#Override
protected void onCreate(Bundle savedInstanceState) {
bundle = getIntent().getExtras();
if(bundle == null)
bundle = StbApp.getTempBundle();
setContentView(R.layout.quest);
setupView();
super.onCreate(savedInstanceState);
}
#Override
protected void onResume() {
soundtrack.startFX(R.raw.fx_execution);
super.onResume();
}
#Override
protected void onPause() {
StbApp.getTempBundle().putInt(Victim.VICTIM, bundle.getInt(Victim.VICTIM));
soundtrack.stopAllFX();
super.onPause();
}
#Override
public void onClick(View view) {
if (view == mainMenuBtn){
//TODO Continue Function
Intent intent = new Intent(this, TitleScreen.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
StbApp.setContinueBtn(true);
StbApp.getLastActivity().setClass(this, Punish.class);
startActivity(intent);
}
if (view == okBtn){
if (StbApp.getPenalty() == PenaltyType.LEAVE){
StbApp.getPlayer().remove(bundle.getInt(Victim.VICTIM));
StbApp.setNumberOfPlayer(StbApp.getNumberOfPlayer()-1);
}
if (StbApp.getNumberOfPlayer() == 2 && StbApp.getPenalty() == PenaltyType.LEAVE)
startActivity(new Intent(this, GameOver.class));
else {
startActivity(new Intent(this, Round.class));
}
}
}
#Override
public void onBackPressed() {
return;
}
private void setupView() {
float textSize = (float) getResources().getDimension(R.dimen.standard_text_size)/getResources().getDisplayMetrics().scaledDensity;
buttonContainer = (RelativeLayout) findViewById(R.id.container_button);
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) findViewById(R.id.container_button).getLayoutParams();
params.setMargins(0, 0, 0, (int) (StbApp.AdHeight*1.3));
buttonContainer.setLayoutParams(params);
bgImg = (ImageView) findViewById(R.id.imgv_girl);
Log.d(TAG, "PlayerSize " + StbApp.getPlayer().size());
nameTxt = (TextView) findViewById(R.id.text_victim_name);
Log.d(TAG, "PlayerSize " + StbApp.getPlayer().size());
Log.d(TAG, "PlayerIndex bundle.getInt(Victim.VICTIM) " + bundle.getInt(Victim.VICTIM));
nameTxt.setText(StbApp.getPlayer().get(bundle.getInt(Victim.VICTIM)).getName());
nameTxt.setTextSize(textSize);
questTxt = (TextView) findViewById(R.id.text_quest);
switch (StbApp.getPenalty()) {
case LEAVE:
questTxt.setText(getResources().getString(R.string.punish_leave));
break;
case DRNK:
questTxt.setText(getResources().getString(R.string.punish_drink));
break;
case UNDRESS:
questTxt.setText(getResources().getString(R.string.punish_undress));
break;
}
questTxt.setTextSize(textSize);
mainMenuBtn = (Button) findViewById(R.id.button_mainmenu);
mainMenuBtn.setOnClickListener(this);
okBtn = (Button) findViewById(R.id.button_ok);
okBtn.setOnClickListener(this);
}
#Override
protected void onDestroy() {
if (bgImg.getDrawable() != null){
bgImg.getDrawable().setCallback(null);
bgImg.setImageDrawable(null);
}
super.onDestroy();
}
What I need would be an alternative for onDestroy, onPause and onResume.
A solution could be using a ViewFlipper/ViewSwitcher instead of jumping activities and then placing the adsView over or under the ViewFlipper/ViewSwitcher - It will however probably require quite a large re-write of your app.

Android - set random button image clickable

I'm having touble in making my random generated image (which is read as a button) become clickable which leads to each different activity for each different image. So the random images work perfect actually, the only problem it's not clickable Here's my code
final Button imgView = (Button)findViewById(R.id.top1);
Random rand = new Random();
int rndInt = rand.nextInt(4) + 1;
String imgName = "img" + rndInt;
int id = getResources().getIdentifier(imgName, "drawable", getPackageName());
imgView.setBackgroundResource(id);
On my layout, I specified the id top1 as a button.
So the above code will look up to my drawable images, which have the names 'img1.jpg', 'img2.jpg', 'img3.jpg' , and 'img4.jpg'.
So what I wanna make is something like, when 'img1.jpg' is generated, it becomes clickable and leads to for example: Activity1.java , for 'img2.jpg' the intent goes to 'Activity2.java', etc.
Thanks much in advance. I'm open for any kind of solution :)
UPDATED:
Here's the full code of my Main class:
public class Main extends Activity {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_x);
final Button imgView = (Button)findViewById(R.id.top1);
Random rand = new Random();
imgView.setOnClickListener(new ActivitySwitch(1,this));
imgView.setOnClickListener(new ActivitySwitch(2,this));
imgView.setOnClickListener(new ActivitySwitch(3,this));
imgView.setOnClickListener(new ActivitySwitch(4,this));
int rndInt = rand.nextInt(4) + 1;
String imgName = "img" + rndInt;
int id = getResources().getIdentifier(imgName, "drawable", getPackageName());
imgView.setBackgroundResource(id);
}
and here the ActivitySwitch class:
public class ActivitySwitch implements OnClickListener{
int imageNo;
Context context;
public ActivitySwitch(int imageNo,Context context) {
super();
this.context=context;
this.imageNo = imageNo;
}
#Override
public void onClick(View v) {
Intent it=new Intent();
if(imageNo==1)
{
it.setClass(context, ProjektAID.class);
}
else if (imageNo==2)
{
it.setClass(context, ProjektADH.class);
}
else if (imageNo==3)
{
it.setClass(context, ProjektBOS.class);
}
else if (imageNo==4)
{
it.setClass(context, ProjektBROT.class);
}
}
}
There is a way: create a new class
class ActivitySwitch implements OnClickListener{
int imageNo;
Activity context
public ActivitySwitch(int imageNo,Context context) {
super();
this.context=(Activity)context;
this.imageNo = imageNo;
}
#Override
public void onClick(View v) {
Intent it=new Intent();
if(imageNo==1){
it.setClass(context, Activity1.class);
}
else{
.......
}
startActivityForResult(it,any_integer_value);
}
}
And then in the Activity set:
imgView.setOnClickListener(new ActivitySwitcher(randInt,this);
if this is a button, simple implement the function of onclicklistener of button and call the respective activity from text it gets... ping me if u didn't understand..

Categories

Resources