0

I'm new at Android programming so I want to ask about Android's behaviour.

I'm using baseadapter with ListView. So at first, I show "a.xml"'s content at ListView.

Then, when I clik an Item, it shows "b.xml"'s content at same Listview.

At that point, when I click "back button", app is closing. But what I want is, turn back to "a.xml"'s content.

Is this possible? Or should I make this contents with "Activity" and create "b.xml" in a new acitivity?

Regards.

sleepy
  • 167
  • 1
  • 2
  • 9
  • Possible duplicate of [Android - How To Override the "Back" button so it doesn't Finish() my Activity?](https://stackoverflow.com/questions/3141996/android-how-to-override-the-back-button-so-it-doesnt-finish-my-activity) – Yasin Kaçmaz Sep 12 '19 at 10:46
  • Unfortunately no, it's not about between layouts in baseadapters. What I want to know is, is it possible to go back at ListView's "old" and "new" layouts. – sleepy Sep 12 '19 at 10:49
  • You can override onBackPressed in your activity, but first you should make a proper research, before asking a question. – barotia Sep 12 '19 at 10:51
  • @sleepy Unfortunately your question is different. Your title says understanding back button behaviour while you are searching for listview adapter changes – Yasin Kaçmaz Sep 12 '19 at 10:52
  • 1
    @sleepy Please search for `RecyclerView`. You can swap adapters, update adapter state, update specific item state. More flexible than your `ListView`. Please follow codepath' s `RecyclerView` guide: https://guides.codepath.com/android/using-the-recyclerview – Yasin Kaçmaz Sep 12 '19 at 10:55
  • @yasinkacmaz actually I tried RecycleViewer but couldn't handle some problems with it, so I choose to continue baseadapter, but I'll check that link, thanks! – sleepy Sep 12 '19 at 11:01
  • 1
    Do as he says. RecyclerView should be the default tool to present lists. – Fustigador Sep 12 '19 at 11:17

1 Answers1

0

By default, back button closes the Activity in which is located. I advise you to open the detail content of the item of the ListView in a new Activity. What you want to achieve is doable, but I think you should learn to walk before learning to run.

Fustigador
  • 6,339
  • 12
  • 59
  • 115