In Android, how do I set the focus on a specified view:
View. requestfocus ();
Large scroll bar settings:
Listview. setfastscrollenabled (true );
The edittext cursor is on the right, and the input content is from right to left:
Android: gravity = "center_vertical | right"
Or
Edittext. SetGravity (gravity. Right );
After edittext settext (), the cursor automatically runs before the first character. You can set the cursor manually:
Edittext. setselection (position); // position indicates the cursor position. It is set to the length of Characters in the edittext input box, And the cursor is the last
To obtain the current cursor position in edittext:
Edittext. getselectionstart ();
Retrieve the Status Bar Height
Decorview is the top-level view in the window. You can obtain the decorview from the window. Then, decorview has a getwindowvisibledisplayfThe rame method can obtain the display area of the program, including the title bar, but not the status bar.
So we can calculate the height of the status bar.
Rectframe = new rect ();
Getwindow (). getdecorview (). getwindowvisibledisplayfRame (FRAME );
Intstatusbarheight = frame. Top;
Obtain the title bar height:
The getwindow (). findviewbyid (Windows. id_android_content) method obtains the view that the program does not include the title bar, and then you can know the height of the title bar.
Intcontenttop = getwindow (). findviewbyid (Windows. id_android_content). gettop ();
// Statusbarheight is the height of the status bar requested above
Inttitlebarheight = contenttop-statusbarheight;
// Hide the keyboard
(Inputmethodmanager) getsystemservice (input_method_service). hidesoftinputfromwindow (youractivity.This. getcurrentfocus (). getwindowtoken (), inputmethodmanager. hide_not_always );
// Display the soft keyboard. The control ID can be edittext or textview. (Inputmethodmanager) getsystemservice (input_method_service). showsoftinput (Control ID, 0 );
Alertdialog. Bulder of the two buttons:
Newalertdialog. Builder (this). setmessage ("delete this item ")
. Setpositivebutton ("OK", new dialoginterface. onclicklistener (){
Public void onclick (dialoginterface dialog, int which ){
Deleteinfo (ID );
}
})
. Setnegativebutton ("cancel", new dialoginterface. onclicklistener (){
Publicvoid onclick (dialoginterface dialog, int which ){
}
}). Show ();
Set whether the edittext has a cursor:
Android: cursorvisible = "false"// If it is false, no cursor is selected.
Or edittext. setcursorvisible (visible );
View
···
GetlocalvisiblerectReturns a filled rect object, which is the rect size of the view. The left and top values are all 0.
···
GetglobalvisiblerectObtains a view area of the global coordinate system and returns a filled rect object. This rect is based on the overall Screen
···
GetlocationonscreenCalculate the x and y values of the view in the global coordinate system. (Note that the value is counted from the top of the screen, that is, the height of the notification bar is included) // obtain the absolute coordinates on the current screen
···
GetlocationinwindowCalculates the X and Y coordinates of the view in its widnow.
···
Getleft,Gettop,Getbottom,Getright,This group is used to obtain coordinates relative to its father.