Switch over tab previous data is coming - java

I have added a tab bar in my application with four tabs like home stock etc .In that tab bar I have used a nested activity using activity group for all tabs. By default, the home page will show up to the user. If I switch stock tab I am calling stock activity group class from stock activity class. In stock activity I have edittext view with list view. If the users enters 'a' or 'A' value into textwatcher listener I list the value in listview. If I click home tab and come back to the stock tab, that value in listview shows up again. Can anybody tell me how to avoid that?

I solved this problem using ontabchangelistener

Related

Content of Textview is deleten when i execute the intent(Android Studio)

For example i have an app to make a shopping list.First activity shows the content of the list.Second one is to add items to the list and it has textviews and button.I used textviews to add items to the list.If you click any textview, related item is added to the shopping list.But you need to click the button to go without adding anything.And i am using an intent for this but if i click that button everything i added the list earlier is deleted.What is the problem and solution(s)?ty
Pls add code ..
however I think the problem can be solved if you need to pass all the data to the 2nd activity and rcv the intent...and when you set the onclick listener for the button in 2nd activity...all data need to be passed back with the intent and set on the list.
If you add the code it will help

Do I have to keep the fragment id's inside navigation graph as same as menu item id?

I am trying to understand the code structure of default Navigation drawer created in android studio 3.6.3. In Navigation drawer when menu item is clicked it shows it corresponding fragment layout. I am trying to understand the mechanism. I have found that the navigation graph fragments id name and menu item id name are both same. I have first changed the menu item id name and called inside main activity using (R.id.menu_id). And when I launch the application the navigation menu were not functioning. Then I renamed the menu id name to as it was and changed the fragment's id name. But unfortunately after launching the app the menus didn't functioned. When I kept the both name same the menu works.
Inside (resource/navigation/mobile_navigation.xml).
Inside (resource/menu/activity_main_drawer.xml)
Inside (java/MainActivity.java)
Need someone guide on am I understanding wrong or not.

How to set a specific text with the word in the list view?

I am creating a list view by adding specific courses on the main page in Android app.
When I click on one of the ListView items (courses), I will go to a new page using intent. In that new page I would like the text to be replaced with the name of the course that I clicked on.
Is there any example showing how I would do this? I cannot show all my code cause there are multiple pages and fragments.

Refreshing a fragment in a tablayout?

I'm developing an application in which I have used a tab layout, I want to refresh my fragment when I used to click on button. There is a counter on tab which shows number of users, but when I press the delete button, it delete that user but the counter remain same, to refresh it I have to again run that tab which is hard to do again and again. So is there any way to refresh it automatically with the counter value change.
I believe the tab is part of the parent activity and all other fragments are attached to it through a view pager. One of the easiest methods that you can do is write a callback to activity from fragment whenever the button is clicked and update the counter value. You can read more about it here: Fragment Communication

Using EditText in Activity Group

In my application i am using tabhost. And to control different activities i am using activity group. I have Activity A from which i am going to activity B. Activity B contains Edit Text, Spinner, Button etc. Now when i scroll the Activity B and press the device Back Button than it does not go to the previous Activity. It goes out of application.
Kindly suggest the answer.
This is the way the Activity lifecycle works for Activity Group. Try using fragments instead of activity group with your tabhost to get your movements. Also, please edit your question title to more accurately reflect the actual question.

Categories