Questions tagged [oncreate]

onCreate refers to one of the lifecycle methods for several components on the Android platform.

The onCreate method is a lifecycle method of several Android components like Activities, Fragments, Services etc.

For activities and fragments, this is the first lifecycle method to be called when that component is first created. It can also provide a Bundle containing the component's previously frozen state, if there was one. This method is generally used to setup the component (for example in an Activity this would translate to creating the UI views, binding data to widgets etc).

More information can be found in:

995 questions
0
votes
1 answer

Activity crashes after button click

I currently have this in and android activity but when the button is clicked the application crashes. I cant find what;s wrong. public class SearchActivity extends Activity implements OnClickListener{ private ListView recipes; Intent…
0
votes
2 answers

Create a class within main activity

What is the best way to load a class within the onCreate statement of an activity? I have two classes, one (titled second) is to be "loaded" when the main activity begins. Hopefully my example code will better explain what I'm trying to…
MADPADGE
  • 113
  • 2
  • 12
0
votes
4 answers

Android passing a variable from a public void to onCreate

im wanting to get a String out of a public void and into my onCreate so i can Log it to check the hash is working. but i'm not sure how to do this heres the my code public class ChooseTeamActivity extends ListActivity { private static final…
iamlukeyb
  • 6,487
  • 12
  • 29
  • 40
0
votes
1 answer

How to display a ProgressDialog after the main view has been drawn. Android

Hi my MapView app takes a long time to load up so I wanted to display a horizontal style ProgressDialog whilst it loads up. When I tried to display the dialog in the onCreate/onStart methods the dialog just showed up at the end with 100% complete, I…
Ollie
  • 473
  • 3
  • 7
  • 19
0
votes
2 answers

onCreate wasn't called by the main class

I've read a lot of articles but none of them could fix my problem of not calling the onCreate-method in the class XMLParsingExample. The log-statement in the onCreate didn't show output and tracing shows that the class is exited after boolean…
Qwyrp
  • 147
  • 1
  • 1
  • 11
-1
votes
2 answers

Getting the position of a list item in Android

So I have this class here: package phil.droid.game; import android.content.Intent; import android.content.res.Resources; import android.os.Bundle; import android.view.View; import android.widget.AdapterView; import…
-1
votes
1 answer

Android: OnCreate xml Inflate Error?

These are apart of my Activity code @Override protected void onCreate(Bundle savedInstanceState) { Logger.i(TAG, "onCreate"); super.onCreate(savedInstanceState); MobclickAgent.onError(this); …
stream
  • 369
  • 1
  • 7
  • 18
-1
votes
2 answers

Why is it important to initialize Array Adapter inside the onCreate() method?

ArrayAdapter bigSquash = new ArrayAdapter(this, R.layout.adapter_xml, onPointString); Whenever I initialize this array adapter outside the onCreate() method an error is generated, whereas when I initialize it in the onCreate()…
-1
votes
1 answer

App crashes when changing into light to dark mode

In my main activity I'm attaching two fragments and using tablayout. Whenever I change light to dark or dark to light, I'm getting this errorenter image description here Process: com.umobi.scantags, PID: 24666 java.lang.RuntimeException:…
-1
votes
3 answers

Save data in ArrayList in activity

I am a new android programmer. I have 4 activities: A B C D. The order is A -> B -> C -> D -> A and A -> D using buttons. I want to save data in ArrayList that is in activity D. The problem is that when I move from D to A and come back to D, the…
ersa
  • 81
  • 7
-1
votes
1 answer

How to pass data from onCreate() to onSaveInstanceState()?

I have an onCreate() function and an onSaveInstanceState() function in my Main Activity. I have declared a Map in my onCreate() and I want to access the keys of that Map in my onSaveInstanceState() function, so as to save them to the outState…
-1
votes
1 answer

Opening of first option navigation bar as soon as application starts java

I am making an android project and i am a using bottom navigation bar with activities.While I click on the navigation bar buttons it works perfectly fine but when i start the application it shows me just a navigation bar .I want the first navigation…
-1
votes
2 answers

Android - return to previous activity without re-creating it

I have a database of >100 objects. Each object has a specific image filename, subject string, title string and pdf filename. I have an activity that is a grid view of objects. When first created the grid view will load an array of objects to…
Nicholas Farmer
  • 773
  • 7
  • 32
-1
votes
1 answer

Use Async Task in oncreateview

Is there a way to overwrite the "week_kg" variable with the async task in the oncreateview method? The async task overwrites the variable, but the View is already created and doesn't contain the new value. It's a Rest Communications with a Node.js…
-1
votes
2 answers

Why does my Google Map keep creating new map instances after Firebase onDataChange() method triggered?

I am having trouble updating the Google Map on my MapsActivity when reading in a coordinate from Firebase. I want to have it so that whenever a database change is detected (this point's latitude or longitude changes), the marker that is on the map…