Newbie in Android development. Implement several different processes in an activity - android

I'm begining to learn android development, and I'm trying to make an app just to learn the language and philosophy.
This app, has to show an image in the middle of the screen, a button below, and a chronometer in the right side. When the app starts, the chronometer has to begin a countdown. When the user press the button, a blur effect has to be applied to the image, and the seconds left to finish the countdown increase by 10.
I almost know how to program the blur efect to the image, the button press, and the countdown and increase by 10 whenever the button is pressed. But I'm not sure about putting all together.
As far as I know, it should be done by designing an activity, and putting inside the activity the image, the button, and another image or a set of changing images or text for the countdown clock. But as I advance in my studied, today I have read that in order to manage different actions in an activity it is neccesary to do it by using fragments. And I have found much complex programming fragments than activities.
So the question is: can I make what I'm trying to do by a simple activity and defining classes and methods for the image effect and the countdown clock or have I to make it with fragments?
Thank you very much.

today I have read that in order to manage different actions in an activity it is neccesary to do it by using fragments
To be blunt, either you either misunderstood what you read, or you are reading the wrong material.
can I make what I'm trying to do by a simple activity and defining classes and methods for the image effect and the countdown clock
Yes.
have I to make it with fragments?
No. It is possible that the whole UI might be a fragment, particularly if it might be shown alongside something else in some cases (e.g., a tablet) and not in others (e.g., a phone). And there is nothing stopping you from making that UI using several fragments, though that would be rather unusual.

As others have already conveyed, no need to go with fragments.. Activity wud suffice.. As far as putting it together is considered, I guess you need to learn more about layouts.. Layouts are the files which basically help you put things on UI as you want it to look like.. There are plenty of material available online for understanding layouts.. Happy learning.. :)

Related

Overriding Android Chronometer class

I want to override the android chronometer class. I want it to inflate a custom XML layout and to also have a quicker update interval.
I've found one that modifies the update interval from the default 1s to 0.1s on github.
But I want to do more and have imageViews or Buttons display the time instead of the default textView it uses. I haven't really done this before except for a recycle view, so some explanation would be nice.
My end goal is to have an efficient stopwatch with custom digits and display, like the one found on HTC one M7 in the default clock app or any Samsung phone. I also need it to run in its own Fragment and be able to handle orientation changes and the activities onPause() or onStop() without losing any time.
Would it be better to use Intent Service and a Results Reciever? if so how would i accomplish this?
Chronometer is good for certain extent, but instead of customizing it you can create your own custom layout and display the time based on your requirements using a handler which would be the best solution for your problem.Find the link below for example
http://www.shawnbe.com/index.php/tutorial/tutorial-3-a-simple-stopwatch-lets-add-the-code/

Need Advice to Use Fragment on Android Studio

here i want to develop an app that can run a simple quiz for psychology character test, but here i need some advice on how to show the question on the activity. Because i want to showing each question without moving to other activity.
This is my temporary layout (it's still ugly XD), but i want the question can appear on the inside of that red box. And when user press Next button, the question inside that box can changed but before it change the app has been stored the answer of previous question.
I really don't know how to use fragment or something like that.
NB. This is my mainActivity look :
For your app I would recommend not to use fragments at all, it will make your app much slower than it can be.
What I would do in your case, is only load the new question in the textbox on pressing next, and call an asynchronous function (asynctask) to perform the storage of the answer. This way the user sees no delays whatshowever.
If getting the next question required a server connection, use a progress dialog in between to show the user something happens.
Agree with Bas van Stein, using different fragments will slow down the app. What you could do is separate frequently changing part of your screen (e.g. question with answer options) into a fragment and reload it's data on Next/Answer button click. This will separate the code and make it easier to maintain and change it later.
On the other hand you could do it in the activity itself if you don't want to use fragment.

How to save a screen state in Android similar to the BackStack?

i m just wondering about some android ui aspects where i need some advices! Might be, that my idea so far is not the best...
Basically I m working on an app, which plays streams in a player (main screen). The user can select streams in a second screen (tabbar screen), where he can switch between three different lists, each one is in one of the tabs and each tabbarclick starts a new activity (i m not using an ActionBar or sth, I just created an own UI element which consist of three icons, current one selected and the other two starting a new Activity):
ListViewActivity1: dynamically created ViewFlipper with nested ListViews (f.e. country->state->city..) from a database
ListViewActivity2: simple ListView with favorits from ListViewActivity1
ListViewActivity3: simple ListView with UserGenerated content
So far it s working great but I m starting to struggle...
Everytime the user enters the tabbar screen again, I want him to be exactly at the last ListView where he was. So basically I m looking for a way to store the different screens if the user leaves them. I came across onSaveInstanceState(Bundle savedInstanceState), but this doesn't really fit my needs. The ListViewActivity 1 is a really complex list with up to six levels sometimes, which I really don't want to transport in a savedInstanceState! Is there another way?
Actually if I go back in the BackStack, this really saves the different states like I want it to. So it is possible, I just don't find anything like this..
So, question 1: Is there a way to save a view like the BackStack does?
question 2: Is this whole idea of ui-implementation a good solution to set up an app?
thanks for any input!

android: How can I implement first time tutorial like Go Launcher in my app?

Go Launcher have a nice first-time tutorial. it is very similar to Stock ICS first time run. I want to learn how to make the similar tutorial display at the first launch of my app. How can I implement this Transparent view (which interacts with screen objects) in my android app?
I was trying to do something similar using a transparent activity with a viewpager inside it. I wanted static 'tutorial' images that users could swipe through.
One of the answers to my question mentioned an interesting library (called ShowcaseView). It seems like it may be a good fit for your requirements as well.
https://github.com/Espiandev/ShowcaseView
You can either use a FrameLayout or RelativeLayout as root of your Activity/Fragment, and put your "first time" View upon content with a (almost) transparent background, or use another Activity/Fragment themed with a transluscent window. (like this)
I'd rather use an Activity/Fragment, but this is up to you!
I wrote little library That contains a simple component for making ​​a app tour. It`s very restricted to my case but maybe could be your case . Single LessonCardView Showed onstartactivity for the first time or on button click Any criticism ,help or advice will be appreciated. thanks https://github.com/dnocode/DnoLib
You can implement a first-time user guide with the Spotlight library by TakuSemba.
It is similar to the one shared above and it is still well-maintained (as of 2021).
https://github.com/TakuSemba/Spotlight

android: how to create multiply views screen?

I want to create an activity, which shows a question with 4 answers, and at the bottom of the screen i want to place a timer.
I have already found timer example, and i created a question with the answers. the problem that they are 2 different projects and activities, and i am looking for the best way to implement it. i think i can't show 2 activities on one screen, but i can show 2 views or shell i use the ViewGroup, or maybe to copy-paste one of the activities code to another ( its the easiest way but probably the most ugliest way to implement it).
please tell me what is the best way, that i will study and not to waste time to study all the ways and only then to choose one of them.
welcome to StackOverflow.
You are correct in that you cannot display two activities at once. You must instead look into how layouts work in Android by reading some tutorials on the Android developer guide.
For your layout, I would recommend using a LinearLayout with four TextView objects inside it containing the questions (and perhaps your EditText objects below them) as well as your timer. Make sure they are all inside a ScrollView so the software keyboard doesn't force it all to be squeezed up. This is how I would approach it, but I encourage you to read about how layouts work and use the XML resources.
The Notepad tutorial is an excellent way to get started with views and text entry, as well as using SQLite databases.

Categories

Resources