I have two activities here. First activity only has a listview. After I click an item in the listview, the second activity is opened.If I click phone's hard back button, everything is fine, I'll go back to first activity and I can see my listview. However, if I click the back button on the action bar, navigateupfromsametask is called, I go back to the first activity, but I can't see the listview. I already set the first activity to be the parent activity of the second one in the manifest. Does anyone know why I can't see the listview? Thanks!
Related
I am doing a program where I have recyclerview with different options(Options 1,2,3,4,5) that are loaded from web and then displayed in my first activity and when I click on one of the options app goes to second activity.I declared first activity as parent of second activity. So that I can go back from second activity onto first activity by clicking back arrow.
My problem is that when i first open my app recyclerview is displayed correctly
(Options 1,2,3,4,5). But if I click on one of the options and go to second activity and come back to first activity recyclerview is shown one below the other i.e. twice. (Options 1,2,3,4,5, 1,2,3,4,5)
Same thing also happens if I change orientation of my device while on my recyclerview activity.
Thanks
On clicking a button in activity, it open another activity and listview parallelly.
If I select record from listview then it populates in the fields of activity, but if i wont select any list item and press back button, the activity is blank which looks awkward.( the list disappears on pressing back button)
onBackPressed the list and activity both should disappear and I need to go the previous parent activity where it contains button .
How is it possible??
CONTEXT:
I have a simple ListActivity (call it "Activity1") that contains a ListView and a number of menu items.
Clicking an item in the ListView shows a popup dialog.
Clicking a menu item button (let's call it "Button") in the ActionBar starts an Activity (let's call it "Activity2") using startActivityForResult()
PROBLEM: If the user touches a ListView item, generating an onListItemClick() event in the ListActivity and then really quickly touches Button, a onOptionsItemSelected() event is posted to the message queue and processed in due course. This results in the following odd behaviour:
User touches ListView item
User touches Button
User sees dialog generated by onListItemClick() for a split second
Activity2 started by onOptionsItemSelected() starts over top of the dialog
When user finishes with the Activity2, he returns back to the dialog, not right back to Activity1
This is very odd and unsettling. In my experience doing UIs in older GUI frameworks, the GUI framework never allowed the second event to post to the queue so you never had to worry about these things.
QUESTION: Is there a "preferred" design pattern to prevent the user from being able to press Button and have it start Activity2 when my app is already in the process of showing a dialog in response to the ListView item select?
Disable the entire Activity1 view hierarchy until the dialog ends??
Write in your ToS that users with 2 thumbs per hand should use the app with caution.
More seriously, maybe you can check if your dialog is open before starting your activity with either a boolean or Dialog.isShowing()
I have an app in which I am implementing a tab bar with 3 tabs. In first tab I am implementing multiple activities by using activity group.
In this activity group I have 5 activities. In the first activity I am having edit texts, I am getting the data into edit texts from another class and then navigating to another activity by clicking a button. When I am coming back from second activity to first activty I am not able to see the selected data. It is showing the page without selected data.
I don't understand this.
From the documentation:
This class is deprecated...
And now coming to your question, you said:
... When i am coming back from second activity to first activty i am not
able to see the selected data...
It is default behavior of ActivityGroup, when you move forward, your current Activity's state is not saved and when you come back to previous Activity, it is started again and onCreate() is called again.
its because, in Activity Group Implementation, all the activities are re-created and then generates view, and then adding this view in window activity is displayed. So, everytime a new activity is displayed, as activities are re-created.
I have used 2 tabs in my app.
when i click on first tab it is showing an list view( default) and when i click on any particular item in list view it is taking me to the next activity to display the selected data. Here when i click on tab again i want that i should go to the listview screen which is default screen.
but nothing happens on clicking the tab but when i press the back button i m going back on the screen. but i want to go to home list view screen on tab click,
pls help me in this case...
You say you start a new Activity. This one can not call the first Activity where you have the tabs. Am I right that your new activity just shows the two tabs as well?
What you could do is the following:
In the second Activity react to the onclick of the tab. When clicked call finish() to close the Activity.
I am pretty sure, that you don't need to do the following. But I write it, if you need it for something in the future :).
In the first Activity call the next through startActivityForResult(...)
In the first Activity overwrite the onActivityResult method. there you can switch to the tab with the list.