In the following tutorial learning to display the Web page of the HTML source code times wrong: Only the original thread, created a view hierarchy can touch it views, through the Internet to find information:The associated view and controls in Android are not thread-safe and must be handled separately. If you want to update the view, you must update it in the main thread, and you cannot perform the updated
This phenomenon only appears in PhoneGap packaging Sencha Touch wp8.1 program will appear ( only WP8.1,WP8 normal ), other JS framework I tested several (app framework, jquery Mobile), It seems that there is no problem.Let me describe this phenomenon:1, run PhoneGap package WP8 program, open an interface with input box, such as:2. Click the input box to eject the soft keyboard, the interface will move up, such as:3, click the Back button to hide the s
$calledfromwrongthreadexception:
Only the original thread, created a view hierarchy can touch its views.
What the hell is going on here? The reason is that the view components in the Android system are not thread-safe, and if you want to update the view, you must update it in the main thread, and you cannot perform the updated operation on the child thread.In this case, we will notify the main thre
Only the original thread that created a view hierarchy can touch its views. The reason is:The related views and controls in Android are NOT thread-safe and must be processed separately. I use handler to solve the problem.
Handler official description:
A handler allows you to send and ProcessMessageAndRunnable objects associated with a thread'sMessageQueue.Each handler instance is associated with a single
This is mostly always, the thread that is turned on and the UI thread (the main thread) are not the same thread.Runnable方式避免,如下例所示就可以解决这个问题了。 Public Static void = (TextView) Activity.findviewbyid (R.id.loadingscreentextview); Act.runonuithread (new Runnable () { publicvoid run () { loadingtext.settext (ResID);}} );}"Only the original thread, creat
);Buddhistservices_listview.setonitemclicklistener (New Bsinfoonitemclicklistener ());BreakCase 1:Break}}};I believe that according to the code of the comments people basically understand what is the reason for it, simply speaking, the network request is a time-consuming thread, but the parsing from the web to the JSON on the ListView is not a time-consuming thread, but the main thread, is the UI update thread, so that the main thread and the UI thread is put together, The result is that the rea
View components in Android are NOT thread-safe. to update a view, they must be updated in the main thread. Update operations cannot be performed in subthreads. Therefore, the message mechanism can be used for updates.
Declare a handler to process the message first.
private Handler handler = new Handler() { @Override public void handleMessage(Message msg) { setContentView(child); } };
Then, send a message to handler in the method of the event triggered in t
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.