RoomInfoActivity.java: http://pastebin.com/L9fFsFeH
(note: this is the 3rd activity launched by the same application, not that it should matter..)
AndroidManifest.xml: http://pastebin.com/QbvQaTf3
room_info.xml: http://pastebin.com/DFNABSNF
Image: http://dl.dropbox.com/u/16952797/temp_stuff/elfapp_ss04.PNG
(note: when I click on the button, "nothing" happens.)
Description: So what happens is the code compiles just fine, and the .apk is launched and run without any issues, but the RoomInfoActivity doesn't reflect the changes that are supposed to be made (such as changing the text of the TextViews and Button) when I click on the button. I'm looking for the least complicated way to do these.
EDIT: I have now made a change, I added this line buttonCleaned.setClickable(true);
under this:
rumInfo.setText(getIntent().getExtras().getString("entry"));
buttonCleaned.setText("Färdig med städningen");
rumStatus.setText("Status: "+checkStatus());
Is your onClick() method ever called? I think you need to set the Activity as a click listener on the button, using the setOnClickListener method.
Related
When I change the screen size in the multiview / split screen mode, the onCreate function in MainActivity is called again.
Because in onCreate I have a ProcessLifecycleOwner observer:
ProcessLifecycleOwner.get().GetLifecycle().AddObserver(this);
I don't want it to be restarted ... How do I know that onCreate has been called before?
I know you can add:
android:configChanges="screenSize"
in the manifest, but unfortunately needs to "refresh the layout" when resizing.
Android is going to manage the life cycle, and the programmer needs to deal with all eventualities. On this page, there's an abbreviated diagram:
That would indicate that you would need to manage the observer in the onStop().
I have an app that uses this RibbonMenu and I wanted to know if it was possible to use the menu items to change the ContentView of the Activity instead of another activity to reduce the size of my app. I've tried doing this already,and it changed the content view perfectly, but i was not able to press the home button. I'm in a bit of a rush here, but i'll try to post code if anyone asks for it. thank you!
Menu items is UI element. It does nothing by itself. It however can trigger some more actions in your code. As for changing activity layout, yes, you can call setContentView() at any time you want.
to reduce the size of my app
this is not the way optimalizations should be done
I am experiencing a weird behavior in my app.
I have an Activity with a ListView. When you click on an item in the ListView, a TimePickerDialog is shown.
If I hit the home button after closing the dialog, and then reload the app, the TimePickerDialog is shown automatically again.
Now, I don't know why this behavior happens. I have logged messages at different points in the app to try to determine how it is triggered but to no avail.
I even added this line:
Log.d("TEST", "TEST");
inside the constructor of the TimePickerFragment and it is not getting fired! Yet the dialog is showing up!
What is going on here?
The activity will save the state. So it will also save state for managed dialogs. When you come back, it will restore. Since it is already created, constructor wont be called. As far as i know if you do not let the activity manage the dialogs, this behavior will not occur
Thanks to nandeesh's answer, I was able to figure out how to fix that behavior.
Since my dialog was managed, I had to call the dismissAllowingStateLoss() method on my dialog instance.
Works like a charm now.
I have a button which is basically used for start/stop. So initially the text of the button is set to start. I attached a OnClickListener to it. So whenever it gets clicked i change its text. So if it was start it become stop and vice-versa.
The problem comes when i change my phone view from portrait to landscape or vice-versa the button text gets reset.
So for example I clicked the start button---it changed to stop. Now if I tilt my phone to change the view the button text gets set to start again.
Am I using the button in a wrong way?
You should save your button state. When screen orientation changes, onCreate is called and all your app variables are re-intitialized. Read more here http://developer.android.com/reference/android/app/Activity.html
No, you are using the button in the right way.
The thing what you are seeing is "configuration change". When you are tilting your device, Android recreating your activity and recreating all it's views (so, they getting default captions as them described in XML).
You need to do the
disable configuration changes for your Activity. To do so, add the following to your manifest's activity tag: android:configChanges="orientation|keyboardHidden". It is not suitable, if you have different layouts for landscape and portraint orientations, when you need to...
handle the configuration changes by overriding onSaveInsatnceState method of your Activity, save a state there and then use it in onCreate method.
See this article for further explanation
i am making an andriod application in which i need to go from one page to another on a button click. i have tried several things but nothing worked out.
Okay, so given these are different .java files, and each has it own Activity (so, different Activities) what you want to do is call an intent as such:
Intent myActivity = new Intent(class1.this,class2.class);
main.this.startActivity(myActivity);
If its in the same Activity, (which I dont recomend) just call setContentView() again