[Q] How to organise different screens? Activity or layout? - Android Q&A, Help & Troubleshooting

I'm designing an App with several layers of menus (on the screen, not from the menu button) which lead to several content pages each, so in total I'll be looking at probably 6 screens of Menu and about 30 content screens (just a picture, text and some buttons).
Should this be just 1 activity for the entire application and with each menu and content page loading a different layout xml? If so how do I do change the layout?
Or should each menu screen and content screen be its own activity as well as having it's own layout xml?
Thanks very much for any help.

I usually use dialog box for simple user infos and I prefer activities to do something more complicated, but it's my opinion. I prefer activities because are simplier than using different dialog boxes or anything else, and so my code doesn't become an incredible mess

I don't think it would work to have dialog boxes to display buttons, like I need for my menus or content pages.
If I did only use 1 activity for it, what's the best way to redraw the layout from a different xml when you click a button? Just have the onClickListener call setContentView(R.layout.new_layout)?

PrometheanFire said:
If I did only use 1 activity for it, what's the best way to redraw the layout from a different xml when you click a button? Just have the onClickListener call setContentView(R.layout.new_layout)?
Click to expand...
Click to collapse
Ok, I understand your needs. Unfortunately I didn't use a new layout in the same activity after a button click, it should be tested.
For my game, I have on the same screen different buttons, textviews, and imageviews that appears and disappears, even after a button click. I putted all of them in the same layout xml (one above the other, what a mess!) and I set the different visibility suitably the buttons clicks (the OnClickListener). It works for me because I have 7-8 items to manage, but maybe not so smart for a lot of different items.

In general, Google recommends using different activities, I remember reading about it in the Dev Guide somewhere.
Although maybe your case is different.

The default recommendation of Google is to use activities. But it does depend on your usage - if everything you are doing is related to the same "activity" (for want of a better word), it may make good sense to keep everything in the same class.
You should also think about what behavior you would like the app to have. Do you want the user to be able to use the "BACK" button to step backwards in your menus? If so, it may make sense to implement this as multiple activities (which will give you this behavior for free), rather than implementing it manually.

I think I'm leaning towards activities as from all I've read it does seem to be best programming practice, it just seems a bit of a waste for me to have 1 activity just displaying a menu! However yes, it would be much easier to use activities then just have user press BACK to navigate backwards.
Also with having 1 activity just switching layout it would mean a massive onClick() 'switch' with at least 30 'cases'! I had thought about implementing my own Back button on the screen but that would be a pain to code.
Thanks for the replies, think I'll go with separate activities and see if it works ok, like I said my main concern was that it's a waste of an activity to have it do something so basic!

Maybe ViewFlipper will be useful?

ViewFlipper just seems to add an animation to changing the layout, no? I'm wondering whether I should just change the layout per screen or to start a new activity per screen.
I've worked it out and I've got 27 Menus, each of these is a ListActivity and 62 Content Pages (each of these is an activity calling a RelativeLayout and some onClick Listeners).
In total this is 89 activities, is this too many for one application? I like the idea of having a different activity per page as that means the user can just press the Back button on their phone to go back up the menus rather than coding in one myself. I've got it working with all the menus but only 1 content page and it's ok, but I can imagine that if I add the remaining 62 contents it may get bogged down?
But yeah, is this too many activities for one app? It is likely at a given time the user probably won't use more than 10 of them.

trying to have a single Activity and then have it able to handle every layout you throw at it and its coorosponding functionality will be a nightmare. use multiple Activities. it will also make using the back button alot easier.
http://developer.android.com/guide/practices/design/seamlessness.html#multiple-activities

Thanks, shouldn't take me too long to create all the content (with copy paste and find/replace) so will see how it works like that.

Related

[Q] Editing Text in Browser

Using the default browser I've been finding it very hard to edit text fields at times - ie: Google Docs and generic web forms. On one site in particular I needed to remove a comma from a list of emails in a textbox, and it literally took me 10 minutes to position the cursor correctly. Since the box was scrolling off the screen, clicking in different positions kept jumping around and in general not reliably scrolling, let alone selecting a given character.
I've noticed that a number of Android Apps have that little magnifier-thing to simplify editing, but that doesn't seem to work for the default browser. Is there some other way of accurately editing text in the default browser, or do one of the other browsers work better?
In more generic terms, is there a better method of moving the cursor in Android, given that the Atrix lacks any physical trackpad? There do appear to be a few premium keyboard alternatives out there that include cursor keys, but I don't particularly feel like paying for something that should be part of the stock system (particularly on a phone without arrow keys!)
I couldn't agree more. Having the delete key as the only positioning key sucks. Given the four different keyboard screens on the stock virtual keyboard, each having only a delete key, it's clear that this was a decision rather than an oversight. Stupid. Sure makes me appreciate all of the things I took.for.granted in WinMo.

[Q] create shortcut to directly settings?

Is it possible to create shortcuts on the home screen to point directly to specific settings?
E.G. I would like a shortcut to the USB utitlites setting (Settings>Wireless and network>USB Utilities) for when I want to plug my usb cable in to transfer files.
I'd also like a shortcut to the Wi-Fi settings (Settings>Wireless and network>Wi-Fi settings) to scan and switch network quickly.
You can add shortcuts to the 1st tier of settings, but not below. Other than that, you're looking for a 3rd party app that acts as a shortcut, or Launcher Pro may be able to do it by adding activities as shortcuts.
Thanks johnc. Can you explain how I can set a shortcut to the first tier of settings.
This is my first Android phone and I have only had it for 3 weeks but the more I use it the more unfinished Android is looking. There are just so many basic usability functions that are missing within the core apps. It seems you need to tack 2-3 3rd party apps on everything to make it work properly.
sunseaker said:
Thanks johnc. Can you explain how I can set a shortcut to the first tier of settings.
This is my first Android phone and I have only had it for 3 weeks but the more I use it the more unfinished Android is looking. There are just so many basic usability functions that are missing within the core apps. It seems you need to tack 2-3 3rd party apps on everything to make it work properly.
Click to expand...
Click to collapse
Once you get more used to it you'll be fine. There's obviously a learning curve, but it's well worth it as Android allows you to do so much, but yes, usually with the help of an app or two.
Anyway, to add a settings shortcut, long-hold on your home screen and in the pop-up menu, select "Shortcuts". Then, scroll down and select "Settings". That will give you your settings menu and you can then add anything off that menu to your home screen.
That's instructions for doing it with the TouchWiz launcher, which is the default launcher on stock devices. If you have a different launcher then it may be slightly different, but that's generally it for all of them.
Hope this helps mate

[Q] Scroll ListView programmatically while touching the screen.

Hey guys, maybe the title is little confusing so let's make it clear.
Many of you know the Go Dev Team and the Go Launcher. The Go Launcher has the feature, that allows to scroll the list, while dragging the icon over the boundaries. I need to implement something like this in my app, but I've encountered some problems, maybe my approach is incorrect.
The main problem is, that it is hard to scroll the list while the screen is being touched already.
1. Dispatching touch events to the ListView while touching the screen equals kaboom.
2. Methods like smoothScrollBy are great, but they behave in different way while touching the screen. They will scroll the list only by height of the screen, no matter how many times this method is invoked. After that the ACTION_CANCEL event is generated and I'm loosing control over dragging object, so I can't scroll further.
3. The scrollBy method in View. When using it on ListView it creates empty space while scrolling. I think I am scrolling whole container then, so I don't see any chances here.
And here goes the question. Has anybody tried something like this and can tell more about it?

S-Pen App Idea (Lost Magic + Activator)

Hey all,
I've thought up what I think is a good idea for Samsung's "Smart App Challenge". As you can probably guess by the forum this is in, this would be primarily an S-Pen app, although you could use it without one. I would make this app myself, but have no experience writing apps and if I were to take the time to learn (which I do plan on doing), the contest will be over. *End rambling* Here's the idea:
Have an app that allows the user to press the side button of the pen (or maybe use some other shortcut, eg long press menu, home, etc). This would make whatever you're doing fade and you can write on the screen with your pen. You can assign different symbols or drawings or whatever to perform different actions, such as launching apps, opening bookmarks, changing settings, etc.
It's sort of a cross between "Activator" on jailbroken iOS and "Lost Magic" for the DS. I'm sure this has been thought of before, but no one (to my knowledge) has ever actually done it. Not sure if anyone has the ability to write something like this, but if you do and are looking for an idea, I think this has potential.
Thoughts?
Sounds like a decent idea to me, assuming you use the SPen a lot. I've used mine just a handful of times personally, but your idea makes some sense to me. Gestures for screenshot, specific apps, etc, sounds like a good idea.
I won't be using a TW based ROM any more, so unless the SPen stuff can be compiled into CM9/CM10 I won't be seeing your app but good luck
Thanks for the feedback! Alternatively, you could do this without an s-pen, allowing you to set up different gestures and actions to trigger different events or change different settings.
For example:
Let's say you use your phone as a flashlight a lot, and want to make it easier to access on your non-cm/aokp based rom. Theoretically, you could set long-pressing the home button to turn your flash on. (Or, using the s-pen, you could press the side button and draw a circle or a lightbulb or something.) I know there are a lot of launchers that incorporate simple gesture recognition, but this would have a broader application, changing the way we interact with our phones. Another example, you could set s-pen input to only be used for gestures. So if you wanted to turn your flashlight on, you simply pull out your s-pen and write "light" or draw the gesture of your choosing on the screen and your flashlight turns on. There are so many ways people could potentially do things, and I think there should be an app that focuses on tailoring your phone to best suit your own personal needs.
xxBrun0xx said:
Hey all,
I've thought up what I think is a good idea for Samsung's "Smart App Challenge". As you can probably guess by the forum this is in, this would be primarily an S-Pen app, although you could use it without one. I would make this app myself, but have no experience writing apps and if I were to take the time to learn (which I do plan on doing), the contest will be over. *End rambling* Here's the idea:
Have an app that allows the user to press the side button of the pen (or maybe use some other shortcut, eg long press menu, home, etc). This would make whatever you're doing fade and you can write on the screen with your pen. You can assign different symbols or drawings or whatever to perform different actions, such as launching apps, opening bookmarks, changing settings, etc.
It's sort of a cross between "Activator" on jailbroken iOS and "Lost Magic" for the DS. I'm sure this has been thought of before, but no one (to my knowledge) has ever actually done it. Not sure if anyone has the ability to write something like this, but if you do and are looking for an idea, I think this has potential.
Thoughts?
Click to expand...
Click to collapse
There are several gesture-based app but here's one that pretty much does what you are suggesting.
My Gesture Shortcut Launcher
https://play.google.com/store/apps/...=W251bGwsMSwxLDEsInNvbmcueS5qLm15Z2VzdHVyZSJd
xxBrun0xx said:
Hey all,
I've thought up what I think is a good idea for Samsung's "Smart App Challenge". As you can probably guess by the forum this is in, this would be primarily an S-Pen app, although you could use it without one. I would make this app myself, but have no experience writing apps and if I were to take the time to learn (which I do plan on doing), the contest will be over. *End rambling* Here's the idea:
Have an app that allows the user to press the side button of the pen (or maybe use some other shortcut, eg long press menu, home, etc). This would make whatever you're doing fade and you can write on the screen with your pen. You can assign different symbols or drawings or whatever to perform different actions, such as launching apps, opening bookmarks, changing settings, etc.
It's sort of a cross between "Activator" on jailbroken iOS and "Lost Magic" for the DS. I'm sure this has been thought of before, but no one (to my knowledge) has ever actually done it. Not sure if anyone has the ability to write something like this, but if you do and are looking for an idea, I think this has potential.
Thoughts?
Click to expand...
Click to collapse
It's kind of like the lock screen gestures on cm7, which I really miss, but having it anywhere would be awesome. Great idea!
Sent from my SAMSUNG-SGH-I717 using xda app-developers app
ArborRes said:
There are several gesture-based app but here's one that pretty much does what you are suggesting.
My Gesture Shortcut Launcher
https://play.google.com/store/apps/...=W251bGwsMSwxLDEsInNvbmcueS5qLm15Z2VzdHVyZSJd
Click to expand...
Click to collapse
This looks pretty sweet. Had no idea this existed, but looks interesting. What it has that I don't really like is that big green "G" that's always sitting on top of what you're doing (from what I gather reading the description). I think we need a more elegant way to activate the system.

Mod to set different functions to swipe left and right on home screen

Hello fellow Android users.
I've always been obsessed with customizing the functionality of my devices to make it really practical to use.
I've been playing with the settings of the Xiaomi Redmi 9 for a week now and everything is set to perfection except one thing which is not available in the default settings but would be incredibly convenient, not only for me but for many people too.
I set all the apps I use in one single home screen (not multiple pages). The ones that don't fit there are all in one folder and that uses up only one button slot.
Since I don't have multiple pages for the apps, the swipe left and swipe right functions are available for other useful things, I'd like to set that up to be shortcuts to apps that I use a lot, like whatsapp and gmail. This would also free 2 slots in my home screen.
I suspect there's a way to do it, just don't know how and have tried several google searches like "how to assign left and right swipe functions on android home screen" or "how to customize left and right swipe on android home screen" and many other similar combinations of words. Found nothing.
Does anyone know if there's an app or a mod that allows you that level of customization? I'm a video editor and I'm not very educated in programing android apps or anything similar.
Hope someone can give me a hint. Thanks a lot in advance. Greetings from Barcelona, where many of us are locked down and unemployed :cyclops:

Categories

Resources