Why things get different on Activity and fragment? [closed] - android

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
I want to fetch data and show it in grid view which is in Fragment but I am getting error.But when I tried to implement same thing in Activity it is working fine why it is happening so?..
Why things get different when implemented in Activity and Fragment?
Can Anyone tell what is to be changed and where we can get stuck?
Thanks.

Slow down. Fragments are tough to grasp and implement when you just got started. To get a better understanding work yourself through this guide. Also make sure you experiment with this example project. Both link to the official Android Developers site.
EDIT: To get the basic picture, make sure you understand the Activity lifecycle and how this lifecycle connects to the Fragment lifecycle. To save yourself from frustration over getting stuck, watch this video and concentrate on the image at 6:10. If you want your Activity and Fragment objects to communicate smoothly, you will need to know when and where you can make method calls and callbacks. There's plenty of other useful material, just keep on searching.

Related

Images take a moment to reappear when scrolling back to them in a ListView [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
I am populating a ListView with images downloaded from URLs.
When I scroll the screen the images in the ListView take a moment or two to reappear.
How can I fix that?
I'm guessing you mean the images take a moment to load when you scroll back to them.
The reason this happens is because the Android system has reclaimed the resources that were used to hold these images in the current activity. You need to redownload them when you show them again. This is not ideal, as it looks slow to the user and uses more data.
You can get around this a bit easier with a lazy image loader. This keeps the images in memory, but does not download them until necessary (i.e. they are shown on the screen)
There is a sample here.
Today, there are number of libraries that handle this exact issue, I found the Picasso
most convenient, I also wrote a blog post on this topic that I think you might find useful:
Guide: How to load images asynchronously into a ListView
You could could find there the most used libraries and code samples for how to use them.

How to show a Help or Notice to user in android application [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
i recently created a application so i want to give a descreption or help to the application .
Like a hint or alert so that user can refer this and if he want this show every time or on first time
like this
so after installing the app should give this notice if user dont want that notice he can hide it for ever..
How to show this kind of alert.. i tried with alert but it always displays i want it just like this
You are supposed to create simple custom alertdialog with the custom layout as show HERE
did you check this library, i found it really usefull :
https://github.com/amlcurran/ShowcaseView
The second one is quiet easier then the previous one and its nothing but an AlertDialog and you may keep track of it by persisting its state via shared-preferences or Sqlite Db.
And for the previous case without googling for an opensource project I would recommend you to create your own RelativeLayout and place some imageViews at the respective positions and for persisting the states go by the above mentioned methodology.
use one transparent layout and maintain your help text on it, using images to draw the layout.
check this link it gives some idea for that help layout.
link

How to kill an activity from a different class? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
Being relatively new to Android, I guess I didn't word my question properly. Here is what I am trying to do. Generally when you start a new intent, you finish the old activity by using class.this.finish() . But I want to finish a different class, not the current class. Let's say I have an activity with a button. Clicking the button would take me to a second activity. Now clicking another button takes me to a third activity and simultaneously finishes the first activity. Probably finish is the keyword here and not kill.
You could have a BroadcastReceiver registered in first activity, and send a broadcast from the third activity. Then in onReceive() method of the receiver finish() the activity.
However, re-thinking the design could be a better solution.
This is a question that doesn't have a straightforward answer. Killing activities is not a good design pattern for Android, so my first thought is "don't do this." Of course, that's not very helpful.
We may be able to help if you describe what you're trying to do. We may be able to suggest an alternative that doesn't requiring killing an Activity, or allows one Activity to finish another in a more "approved" manner.
Sometimes the answer to a problem is to suggest a different problem. Like the robot banging against the wall, the problem is not cutting through the wall, but learning how to turn and go on.

create a service to check external database frequently [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I am new in android and i develop an application that receive data from MYSQL external database using PHP.
I need to create a service to check frequently the database if there is any change made on it the end user will get notification , so how i can create this like this service ??
any article to read ?!
thanks in advance
Well, what are the specifics of the service? What are your requirements? Do you just want to poll your database, and then stop the service once data is retrieved. Will you need a separate worker thread to do this work?
You might want to look into Intent Service for this. Documentation on it can be found here
A standard service may be fine too, but I'm not sure what the specifics are for your project, so I would read up them both and figure out exactly which would be best for your needs.
See this SO question that gives a brief outline of them both.
Firstly, welcome to android development.
Unfortunately your seemingly simple example will require you to learn a lot of android concepts so I cannot answer your question as directly as you might like.
That said, the following site is very good for android tutorials
http://www.vogella.com/android.html
I have also compiled a list of android resources on my site that you might benefit from:
http://www.sage42.org/we-recommend/

how to make my two player checkers application ,a one player checkers application [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have developed my first android application i.e. CHECKERS ,which is working perfectly for two players, now some users of my app wants me to add a single player mode as well.
Can you guys plz help me how can I fulfill this demand,How to code for this.Your help will be highly respected.
I used canvas drawing in my app and my class extends SurfaceView implements runnable.
Thanks!
I am willing to help you with ideas:
I assume you already have a project, which works with two players. If you want to achieve 1-player mode without too much pain, you should follow the ideas described below:
Create a ComputerPlayer class, inherit it from your Player class.
Override methods, such as move to occur automatically (at first, start with random moves, don't get delved deep into the AI logic just yet, because first you want to support automatic moves, and then you will want to focus on AI strategies)
Where you send/receive the moves support sending/receiving moves from ComputerPlayer as well (you will not really send a message to the network, but your current project probably uses terminology as "send", "receive")
Test, test and test.
When everything is well, choose an AI strategy, implement it and you are done with the upgrade.

Categories

Resources