Connect the server through the IP address and port

2023-01-20   ES  

----- All the contents of this article come from the user notes on Mu class online, I just sorted it up ----
ImageButton is used to display pictures on the button. So there is no Android: text attribute. And if Android: Text = "I am a button" in the layout file, you will not see any effect in the Android 4.4 environment; 
 Set the background image to fill the entire ImageButton, and set the SRC image to adapt; 
 The text content displayed by Button is recommended to be stored in Strings.xml file
Onclight incident

Three ways to listen to
1. Initialize control; 
 2. Set the monitor; SetonClickListener 
 3. Implement the onClick event. 
 a. Anonymous internal class implementation; object .setonClickListener (New Onclicklistener) 
 b. Independent class implementation; object .setonClickListener (listener instance) 
 c. Interface method. Object .setonClickListener (this) 
 1. Anonymous monitoring event 
 Loginbutton.SetonClickListener (New Onclicklistener () { 

 public void Onclick (view argView0) {{) { 
 // Todo Auto-Generatd Method Stub 
 System.out.println ("My Button was clicked"); 
 2. Independent incident 
 Loginbutton.setonClickListener (Listener); 
 External separation: 
 Onclicklistener Listener = New Onclicklistener () { 

 public void onClick (view v) { 
 // Todo Auto-Generatd Method Stub 
 System.out.println ("The class to trigger"); 
 3. Implement interface 
 Public Class MainAICTIVITITY Extends Activity Implements onClickListener { 
 LoginImageButton.SetonClickListener (this); 
 public void onClick (view v) { 
 // Todo Auto-Generatd Method Stub 
 Log.i ("tag", "third method"); 

Implementing the effect of horse race lamps 
1.textView content is too long, default 

 2. Horse running light effect 
 Method 1: (Only the effect of a single TextView is effective) 
 Android: Singleline = "True" can only be single, the excellent text is displayed as "..." 
 Android: Ellipsize = "Marquee" omission, but there is no horse -raid lamp effect 
 Android: Focusable = "TRUE" 
 Android: FocusableIntouchMode = "TRUE" 

 Method Two: 
 Custom a class inherits TextView, realize the default three constructors, rewrite the ISFOCUSED () method, and return True 
 Change the TextView to (package name+class name) com.imooc.marqueetextViewDemo.marQueetext in the layout file 

 Methods Two TextView can achieve the effect of horse -rater lights because the ISFOCUSED () method is rewritten to return True, forcing the TextView to Focused; and Method 1, the first TextView was focused, and the second TextView did not get obtained. Focus, unable to achieve the effect of horse -raising lights 

 After rolling for a while, you will stop by yourself: Android: Marqueerepetlimit = "Marquee_forever" 

 px, dp (dip), SP 
 1. PX is not recommended in development, PX cannot be used as a reduction according to the resolution; 
 2.DP and SP can be regarded as equal scaling according to the resolution; 
 3. Recommend DP when making length limit in the control, SP is more used to display text size; 
 4. Recommended DP in Android's latest SDK

Use AutoCompletetextView
 1. Initialize control: first declare (Private AutoCompletetextView ACTEXTVIEW;), and then initialize (AUTOCOMPLETEXTVIEW) FindViewBy (;); 

 2. Create an adapter 
 Adapted input content and data source 
 ArrayAdapter <string> adapter = New ArrayAdapter <string> (Content, Resource, Objects); 
 Among them: Content —This, an object of context; 
       Resource —— Android.R.Layout.simple_List_item_1 (XML file similar to Activity_main), a corresponding layout 
       Objects- (parameter Objects is a data source of the string type array) 

 3. Initialize the data source (the content of the data source is matched the content entered in the text box) 
 Private String [] res), "Data 1", "Data 2", "Data 3", "Data 4 ..."}; 
 Add him and add to adapder 
 ArrayAdapter <string> adapter = New ArrayAdapter <string> (this, 
 Android.Rayout.simple_list_item_1, Res); 

 4. Bind Adapter with the current AutoCompletetextView control 
 AutoCompletextView.setAdapter (ArrayAdapter); 

 5. Set a attribute in AutoCompleTetextView to make the input enough 3 characters to start matching 
 Android: Completionthreshold = "3"


Use multiautocompletetextView
MultiautocompletetextView is similar to the former 

 Step 1: Initialization control 
 Step 2: Need a adapter 
 Step 3: Initialize the data source 
 Step 4: Bind Adpter with the control 
 Step 5: Set the separator 

 Specific code implementation: 
 ① xml file 
 Android: ID = "@+ID/mctv" 
 Android: layout_width = "Fill_parent" 
 Android: layout_height = "wrap_content" 
 Android: layout_below = "@+ID/Actv" 
 Android: Completinghint = "1" 
 Android: hint = "Please enter the contact name"/> 
 ② Initialization: 
 Private multiautocompletetextView matv = null; 
 "share", "shieke", "adj", "as", "ad", "sh", "sHADFD", "saf", "dfji"}; 

 ③ Specific operation: 
 * Use multiautocompletetextView to implement automatic prompts: 
 *1. Initialize control, remember FindViewByid ( **) method 
 * 2. Need a adapter 
 * 3. Initialize the data source-> this data source to match the text box content 
 * 4. Bind AdaPter and MultiautocompletetextView, call the setadapter () method 
 * 5. Set a few characters before automatic prompts 
 * 6. Set the separator 
 this.Matv = (multiautocompletextView) findViewByid (; 
 matv.setadapter (adapter); 
 // Set the comma to the separator, that is, the end symbol 
 matv.settokenizer (New MultiautocompletetextView.comMatokenizer ());

Use togglebutton
Pick from Miss Xu
Togglebutton default is OFF status 
 Android: texton = "Open" 
 Android: TextOff = "Off" —— Use these two attributes to represent the content displayed in the interface 

 Display the picture through the ImageView control 
 Android: Background = "@Drawable/OFF" to display this picture of OFF 

 Initialize the control in the main activity.xml file 
 1. State first: 
 Private togglebutton tgbt; 
 Private ImageView Img; 
 2. Primary initialization 
 TB = (Togglebutton) FindViewByid (; 
 img = (ImageView) FindViewByid (; 
 3. Surveillance TB switch (setting a monitor for the current TB) 
 Let MainActivityImplements onCheckChanglistener 
 Then set a monitor for TB 
 TB.SetonCheckedChangelistener (this); 

 Method of the listener: 
 Public Void OncheckedChanged 

 The current method is executed when TB is clicked. 
 CompoundButton ButtonView parameter can determine which TB is clicked, buttonView represents the control of the control itself 
 Boolean ischecked parameter is to determine the state of TB, iSchecked represents the state of the control of the control 

 When you click TB, you need to change the picture: 
 Through img.setbackGroundResource (iSchecked? R.Drawable.on:;

Do not skip class
RADIOGROUP attributes Android: OrTentation = "Horizontal"/"Vertical" 
 RadionButton's default is selected by Android: Check = "TRUE" 
 Add monitoring SetonckedChangelistener (oncheckedChangelistener Listener) to Radiography 
 The coverage method Public Void OncheckedChanged (Radiography Gropupup, Int Checkedid) {{ 
 if (Checkid == {// Checkidid is R.ID 
 Log.i ("tag", "You are a boy"); 
 } Else if (Checkdid == {{ 
 Log.i ("tag", "You are a girl"); 


Related Posts

X-axis length, that is, gray level axis_params = [] axis_params.append (0) axis_params.append (x_size) #plt.figure () if name! = None: PLT.TITLE (name) PLT.BAR (Tuple (Keys), Tuple (Values))#Draw a histogram #PLT.SHOW () #Map the ash array as a histogram dictionary, nums represents the magnitude of the grayness DEF ArrayTohist (Grayarray, Nums): if (len (grayarray.shape)! = 2): Print (“length error”) Return None w, h = Grayarray.shape Hist = {} For K in Range (NUMS): Hist [k] = 0 for I in Range (W): for j in range (h): if (hest.get (grayarray [i] [j]): is none): history [grayarray [i] [j]] = 0 Hist [grayarray [i] [j]] += 1 #normalize n = w*h for key in history.keys (): Hist [key] = float (history [key])/n Return Hist #Accut the cumulative histogram calculating new balanced pictures, nums is grayscale, 256 DEF Equalization (Grayarray, H_S, Nums): #Calculation accumulated histogram TMP = 0.0 h_acc = h_s.copy () for I in Range (256): TMP += H_S [i] h_acc [i] = tmp if (len (grayarray.shape)! = 2): Print (“length error”) Return None w, h = Grayarray.shape des = np.zeros ((w, h), dtype = np.uint8) for I in Range (W): for j in range (h): des [i] [j] = int ((nums – 1)* h_acc [grayarray [i] [j]] +0.5) Return des DEF HISTMATCH (Grayarray, H_D): #Calculation accumulated histogram TMP = 0.0 h_acc = h_d.copy () for I in Range (256): TMP += H_D [i] h_acc [i] = tmp h1 = Arraytohist (Grayarray, 256) TMP = 0.0 h1_acc = h1.copy () for I in Range (256): TMP += H1 [i] h1_acc [i] = tmp #Calculation mapping M = np.zeros (256) for I in Range (256): IDX = 0 minv = 1 for j in h_acc: if (np.fabs (h_acc [j] -h1_acc [i])

Some errors encountered during the Activiti process

MySQL InsertorUpDate is updated, and inserts in CAPPADOCIA when there is no existence

TI-RTOS module Drive Example-DAC Module SKY

Connect the server through the IP address and port

Random Posts

3D printing open source slice software Cura configuration step

qt can’t find -lpulse -mailoop -glib, can’t find -lpulse problem

wire flat meter 5800 all -around program

“Programmer Installation B Guide”

I can use the [MATLAB] tool (3) — How to install the MOSEK toolbox