Use of ratingbar and Display error messages

Source: Internet
Author: User

In the layout file:
<Ratingbar
 
Style = "@ style/myratingbar" // use a style
 
Android: layout_marginleft = "10dip"
 
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"
Android: Id = "@ + ID/rbar">
</Ratingbar>

In the styles. xml folder under the values folder
<? XML version = "1.0" encoding = "UTF-8"?>
 
<Resources>
 
<Style name = "myratingbar" parent = "@ Android: style/widget. ratingbar">
 
<Item name = "Android: progressdrawable"> @ drawable/rating_bar </item> // redefine the pattern
 
<Item name = "Android: minheight"> 16dip </item> // minimum height
 
<Item name = "Android: maxheight"> 16dip </item> // maximum height
 
</Style>

</Resources>

Show error message

/*** Display error message ** @ Param C * @ Param edittext * @ Param Str */public static void showedittexterror (context c, edittext, int Str) {selection. selectall (edittext. gettext (); edittext. seterror (C. getresources (). getstring (STR); edittext. requestfocus (); inputmethodmanager Imm = (inputmethodmanager) C. getsystemservice (context. input_method_service); view = (activity) c ). getcurrentfocus (); If (view! = NULL) {Imm. hidesoftinputfromwindow (view. getwindowtoken (), 0 ); // hide the soft keyboard}/*** Display error message ** @ Param C * @ Param edittext * @ Param Str */public static void showautocompletetextviewerror (context c, autocompletetextview edittext, int Str) {selection. selectall (edittext. gettext (); edittext. seterror (C. getresources (). getstring (STR); edittext. requestfocus (); inputmethodmanager Imm = (inputmethodmanager) C. getsyst Emservice (context. input_method_service); view = (activity) c). getcurrentfocus (); If (view! = NULL) {Imm. hidesoftinputfromwindow (view. getwindowtoken (), 0); // hide the keyboard }}

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.