Android Tabs problem - android

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.

Related

Recycler view Scrolling issue

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

android with viewpager When i click on Button in the first fragment I want the app to navigate to another activity

I have two fragments implemented using View Pager. In fragment 1 I have 2 button and in fragment 2 I have list of item.
When I click on particular button in the first fragment I want the app to navigate to another activity.
but this scenario when I click on particular button in the first fragment then It's click on Second fragment list item and open list item detail.
If anybody knows, please suggest me a solution. I need to do this as soon as possible.
Thanks
One thing that came on top of my head is this:
Store your fragments in a ViewPager.
Listen to button click events in your first fragment.
From your first fragment, notify your activity of said click event.
Your activity (which also houses the ViewPager) should respond to the click event by commanding the ViewPager to move to the second page (which also contains your second fragment). You can do this by calling yourViewPager.setCurrentItem().
And there you have it. A fragment that contains button which move the pager onto the next page/fragment.

Get blank activity after using navigateupfromsametask

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!

Issues with activity group

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.

android:how to Reload the TabActivity when tab press?

I have Tab Based Application where i want to Reload the Tab activity when tab are select again.. In my application when i select the Tab again the view are coming as old output It is not reloading the page..so how can i reload the page by clicking the Tab again and again without showing old view?
switching of tabs calls onPause and onResume functions, so in order to refresh the page, cut paste the functionality provided in onCreate to onResume...

Categories

Resources