Every time I want to reprint someone else's article do not have to write their own, good want so easy, but the road is so hard, every time you look at someone else's blog and then you will encounter a variety of problems, People's blog on a few steps, but I will encounter wonderful problems,, hey, now think of Qu wanting a song " There is no difference in the lyrics, although the pain of the bitter didn't see?, but which have all the way to go are downwind, as long as the dream does not admit defeat, and then bitter also do not stop pace. or summarize it yourself!!
First, I added a new button for the app that I used to do, and asked that the button not be pressed before the value returned from the previous activity, so I found a way to use the Startactivityforresult method to get the return value of the previous page. Then assign the value to the variable, set the switch in the page to determine the value of the variable, so that the button can be set to the press, while other content can be set.
Startactivityforresult about the explanation I don't write, refer to others, feel good to write, this is the link address http://www.cnblogs.com/lijunamneg/archive/ 2013/02/05/2892616.html
Problems encountered in the implementation process:
(1) The current page can not get the return value of the previous page, the resulting data has been an error, said to be null, each time in Startactivityforresult no start call callback method, get the intent is null, and then go to jump page, which makes me headache, So I added a log in various places to see the output, helpless to find solutions to the Internet, and finally found the method:
For example: There are onactivityresult methods in the Activity1, there are setresult methods in Activity2, Activity2 should be triggered Activity1 after the shutdown method, but I man The Activity2 android:launchmode= "Singletask" in the Ifest file causes the activity to become a singleton mode, and Activity1 Onactivityresult cannot be triggered. Change the android:launchmode= "Singletask" to Android:launchmode= "Singletop".
And then finally it's ready!! So hard.
(2) When setting the clickable of the button also encountered difficulties, first find the control, and then Setclickable (false), found useless .... Later on the Internet to find methods found written in front of the Setonclicklistener, which makes the previous setting invalid, because there is a piece of code in Setonclicklistener
if (!isclickable ()) { setclickable (true); }
And then change to the back of the good.