Android--Isineditmode

Source: Internet
Author: User

Explain

Indicates whether this View was currently in edit mode. A View is usually in edit mode when displayed within a developer tool. For instance, if the View is being drawn by a visual user interface builder, the This method should return true. Subclasses should check the return value of this method to provide different behaviors if their normal behavior might inte Rfere with the host environment. For Instance:the class spawns a thread in it constructor, the drawing code relies on device-specific features, etc. This method was usually checked in the drawing code of custom widgets.

If you use system-dependent code in the constructor or other drawing-related areas of your custom control, the visual editor will not be able to make an error and prompt you: using View.isineditmode () in your custom views to skip code When shown in Eclipse

Code
 public  class  lockrelativelayout Span style= "color: #0000ff;" >extends   Relativelayout { private  Handler MainHandler = null ; //     public    Lockrelativelayout (context context, AttributeSet attrs) { super  (context, attrs, 0);        Mcontext  = context;  if  (Isineditmode ()) {return  Span style= "color: #000000;" >;    } mainhandler  = (mainactivity) mcontext). Getmhandler (); }}

If you do not add if (Isineditmode ()) {return;}, the code in red will cause visual editing error

I'm the dividing line of the king of the Land Tiger.

Http://stackoverflow.com/questions/15423149/how-to-use-isineditmode-to-see-layout-with-custom-view-in-the-editor

Android--Isineditmode

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.