Milos Gojic

+ Follow
since Jan 02, 2017
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Milos Gojic

Randy Tong wrote:Which tutorial you are referring ?

Udacity android data storage

Udacity data storage
1 month ago

Randy Tong wrote:No, you don't have getApplication() in front.

Sry,you are right but i added this and the same problem persist. Maybe problem is in my provider class,but can't rememer changing anyhing in it.
thanks for effort
1 month ago

Randy Tong wrote:Try this

I already have this lines of code on line 61
1 month ago
Hello i am following Udacity android data storage course.But just hit the wall. We are making pets app in witch user can add,update and delete a pet. In one segment we had to use floating button,and with intent go to another activity, from Catalog Activity to Edit ACtivity. But when i click on floating buton got an error:An error occurred while executing doInBackground() .I do not use AsyncTask doInBackground() method,but understand that my Loader using a AsyncTask class.I also fnd that problem might be that i am trying to display something on doInBackground(). I can't do any GUI work on a background thread,i get this.but i didn't use doInBackground() method directly si how can i change something that i haven't use?I simply don't konow how to fix this


my logcat:
FATAL EXCEPTION: ModernAsyncTask #2
                                                                         Process:, PID: 24569
                                                                         java.lang.RuntimeException: An error occurred while executing doInBackground()
                                                                             at java.util.concurrent.FutureTask.finishCompletion(
                                                                             at java.util.concurrent.FutureTask.setException(
                                                                             at java.util.concurrent.ThreadPoolExecutor.runWorker(
                                                                             at java.util.concurrent.ThreadPoolExecutor$
                                                                          Caused by: java.lang.NullPointerException: uri
                                                                             at android.content.ContentResolver.query(
                                                                             at android.content.ContentResolver.query(
1 month ago

Norm Radder wrote:

Attempt to invoke virtual method 'void android.widget.TextView.setOnClickListener(android.view.View$OnClickListener)' on a null object reference

Do you have code that calls: setOnClickListener?

Yes in main activity, i have an image that when user click on it it send him to this activity...but it works in other activities...only this one is making a problem...
10 months ago
I wanted to use ExpandableTextView, and although it's really simple code only few lines of code i stumbled in problem
I googled it alot and i think that my probem is something about styles.xml ,because i lost preview look on android studio...but can't figured what?
I read somewere about changing styles.sml to styles-21.xml but then getting an error about duplicating something..and again i am lost in dark
I got error:

I changed styles.xml:
And Activity where is my ExpandableTextView:

And my XML:
10 months ago
I wanted to put EditText in array.So that it can be printed several time.I don't want to make several EditText in XML i really wanted to avoid making robust xml.
I planned to make one EditText and then with loop displaying several time.
I did that with text but don't know how to do with EditText.
It should look like this:

Text    Edit text
Text    Edit text
Text    Edit text
Text    Edit text
Text    Edit text

I know for ArrayList and ArrayAdapter but i must make two more class and at the end it's the same like i made several EditTexts in XML... I want to shorten the code writing.I tried everything that i know i lost a day in something that should be an easy task....

my XML:

nad my JAVA:
11 months ago
Hello, I know that this is small and stupid question but, although I am not complelty begginer in java, i am still in beggining on my learning path.
i am making an app where user can buy books. First, all prices books had the same prices and then my "customer" said that he would like to change some prices,and  messed my workflow,my logic and my code....
How to change that.

When user click some book he will able to fill up form.In that form he will find field with quantity.App will automaticly calculate the end price.

This is my first book activity. There is seven. Price of this book is 100

Here is my "Order" activity.Here i am calculating price.Here is price of the first book of 100. But what to do with other prices?

2 years ago
I am making an app where user must enter basic info about self.First name,second name, city and quantity that he or she wish to order.If he or she  skip one field toast will pop up with message what field is skipped. And that is ok.That works but if he skip quantity field I got error on my phone and it send user back on previously activity.When I inspect my LogCat I see error message . Now I know why that message appears.Because it expected to find Integer, if statment. but actually finds String. But do not know how to fix it.The last if/else statemen is an Issue:
Now what i tried so far:
1) Tried to set primitive int as object Integer
2)Tried to use kolicina==0;
3)Tried to use kolicina.equals(null) / kolicina.equals(0);
4)Tried to use .isEmty();

my code:

2 years ago
Hello make long story short, root of my problem and my frustation :

I am making an app with two Floating Buttons

When user click my floating button he will be able to go to dial up screen and call phone number.For some reason doesn't work..

I already have intent,in the same activity, where he will able to go to SMS screen and be able to send a text.For some reason work just fine.

in first case nothing happened.If i put Toast in onClick listener also nothing happens.I just do not know why. Do i need to put another activity in my manifest? but this is not new activity?how to name it in my manifest....or problem is something completly different. When i say nothing happens...well nothing happens.There is no error,or some strange behavior or something else.There is no error message in my LogCat also. It is completly possible to mess up intent but my toast message also doesn't pop up.What leeds me to conclusion that i messed up something with onClickListener. But what?it is completly normal, like other listeners that i used before.Or i am just tired to see elephant in the room. I am on my computer for about 10ish hours

My full code:

my full xml code:

My "problematic" onClickListener is second one..this one:

2 years ago
I'm making an application that consists of the first page that will be a list of books. When you click on a picture book users will be able to flip through, something like a free sample. I was planning to do with Intent.So when someone clicks on a book picture, using the click listener and intent opens a new java class with PDF file. It displayed using PDF VIewer. But although I have no run-time error, on the phone throws an error that my application is stopped.

Surely my logic is wrong.

I inculded library

main_activity.xml with book list:

XML code with PDF viewer:

My JAVA class Mainctivity:

Second java class with pdf viewer:
2 years ago

Campbell Ritchie wrote:  You can use a Map with the id as the key and the price as the value. Alternatively, you can define a MenuItem class and use that as the map value.  You may need two Maps: one for the menu items, one for the items selected by the user.  Alternatively, if you use a MenuItem class and override its equals() and hashCode() methods, you can use a List to hold the items that were selected.

Would you believe me that i thought this also! This is huge step for me,because before, i did not know from where to start, now i at least had some (vague) idea

BTW, they are if-statements, not if-loops. A loop does something multiple times. An if-statement's body is executed only once and only when its conditional expression is true.

I know that,but was so focused on my english ;)

Thanks i will try to fix this issue with maps
2 years ago
Hello everyone, I'm trying to do my Android application. A rather small one
About it ... So application imitates the menu from the restaurant, when the user checks the breakfast, such as Bacon and eggs, enter his name , application on the screen repeats this information. If we want to take two different breakfasts, applications, of course, calculate Prices and prints on the screen.

But what if the user wants to select a number of different dishes, I can not go on forever adding if loops .Or, I can?

Now where I am stuck ... in principle I did not stuck, but I was wondering if there is an easier( and more beautiful to the eye) way to calculate several variables? My code works quite ok but it would look very ugly with   dozens of  if loops. I tried to use switch / case but it can't be used with boolean.I do not know if I can do smething with lists?

How my app looks for now:

My code:

I  will eventually  add more dishes so this is problematic.
Thank you and sorry for my poor english.
2 years ago