How to use id of elements of activity using intent communication - android

In android suppose we intent an activity2 from activity1..so how can we use or get the ids of elements of activity2(such as relative layout etc) in activity1..and code in activity 1 using the element of activity 2

If you are trying to change the UI of Activity1 based on Activity 2 then you should start it as child activity and use onActivityResult.
If you are trying to access some values of Activity1 in Activity 2 then you can pass them via bundle.

Related

Android: i need to navigate to a same activity through different activities and returning back to those activities after im finished

I have two activities one is saved address activity and the other is a cart activity both have a button to navigate to the same page which is map to get the location and after finding the location their redirected to another page which is to fill their house no and after filling them it has a button when clicked I want an event to get back to their starting activities
I used intent extras to put information as key values 1 and 2 in the corresponding pages and checked it at the end but still no use
If I have understood correctly you want to send the information (location, house no) back to your starting activity?
One "dirty" solution would be like:
Intent mIntent = new Intent(mContext, YourDestinationActivity.class);
mIntent.putExtra("location", location);
mIntent.putExtra("houseNo", houseNo);
startActivity(mIntent);
But for this kind of workflow I would use Fragments
A Fragment represents a behavior or a portion of user interface in an Activity. You can combine multiple fragments in a single activity to build a multi-pane UI and reuse a fragment in multiple activities. You can think of a fragment as a modular section of an activity, which has its own lifecycle, receives its own input events, and which you can add or remove while the activity is running (sort of like a "sub activity" that you can reuse in different activities).

Does Android RelativeLayout LayoutParams can set R.id ?

In my app, I create the gridview and then add the view by RelativeLayout LayoutParams.
But how can i call it in another activity?
such as gridview looping the 10 article and hide the icon, i create the edit button to control hide/show the icon. but i dont know how to call it.
Thanks.
Once you switch activities, I don't think you can directly access the ui elements of the previous activity. You should try to send data between activities by creating intents with arguments like this :
Start an Activity with a parameter
If you from activity A to B and you want to pass data back to A, launch A with an intent that has the extra data you need.
Parse the data from the intent and update your UI accordingly.

How to pass intent from 1st activity to second and viceversa?

I have two activities both xml files have an edittext and a button.I want to pass intent of first activity to second and also from second activity to first my teacher have said me to use ON ACTIVITY RESULT AND START ACTIVITY FOR RESULT METHODS
please help me i am a newcomer and its my homework!!!

How to call startActivityForResult from ActivityGroup

I am using tab widget and each tab belong to a activity group. An activity group has several sub activities.The sub activites are added to the activity group via LocalActivityManager.startActivitY from activity group but now i want to use startActivityForResult from instead of startActivity. Can someone help me to accomplish that as LocalActivityManager class does not havestartActivityForResult method..
#Sabya i had been there in the same situation few weeks past. And i have found from my side that there is no way to use startActivityForResult in ActivityGroup. So i found some hacking type of technique to get out of this. First create a static variable of the result you want from startActivityforResult.After doing this,intent to a transparent Activity,in which you doing all those stuff of activityforResult.After getting value you set the value of the static variable that you created in the TabClass,After then finish the transparent Activity

Android sub activity

Iám new in android.
My questions about sub-activity.
Main activity with child sub-activity 1 and 2.
I have a Main activity with 3 buttons with these buttuns i pass values to my child activity number 2 and in child 2 i do something with these values.
When i push the button in child 2 i would return the values to child number 1 and put the values in TextViews.
Now my problem is when i finish child 2 the values return automaticaly to the Main activity.
This not what i want is there solution for this.
Were can i place startActivityForResult . I don't want to place it in the Main activity.
Thanks in advance.
I would add the values as extras to the Intent that you use to start child 1, just as you did when you passed values to child 2.

Categories

Resources