Android implementation of control usage in listing list to show semi-transparent small form effect _android

Source: Internet
Author: User

The example in this article describes the control usage of the Android implementation, which displays a semi-transparent small form effect in list lists. Share to everyone for your reference, specific as follows:

Android controls that show translucent small form effects in list lists, much less directly on the code, all in the comments:

Import COM.HIAPK.MARKET.R;
Import Android.content.Context;
Import Android.graphics.PixelFormat;
Import Android.os.Handler;
Import Android.view.LayoutInflater;
Import Android.view.View;
Import Android.view.WindowManager;
Import Android.view.WindowManager.LayoutParams;
Import Android.widget.TextView; /** * window display semi-transparent hint box in the middle of the widget * usage: 1. New 2. Showprevletter (String prevletter) * @author LL * */public class Prevletterdialog {//form disappears time delay private static FINA
  l int delayed_hiden = 500;
  The class that implements the Runnable interface is private removewindow Mremovewindow = new Removewindow ();
  Changes to UI threads can be implemented in Handler private Handler mhandler;
  Form Manager Private WindowManager Mwindowmanager;
  Display the translucent font frame in the middle of a form private TextView mdialogtext;
  Whether the private Boolean mshowing is being displayed;
  Are you ready to display the private Boolean mready?
  The characters that appear in the form private char mprevletter = Character.min_value;
   /** * Note: The context must be obtained by GetContext () in the visible UI, otherwise it throws an exception. * @param context */public prevletterdialog (context) {//GetForm Manager Mwindowmanager = (windowmanager) context.getsystemservice (Context.window_service);
    The cloth creator was layoutinflater inflate = (layoutinflater) context.getsystemservice (Context.layout_inflater_service);
    Get TextView Mdialogtext = (TextView) inflate.inflate (r.layout.list_position, NULL);
    Set TextView as Visible mdialogtext.setvisibility (view.invisible);
    Show the Mdialogtext through Handler mhandler = new Handler ();
        Post enables you to invoke the UI thread in multithreading and change Mhandler.post (new Runnable () {public void run () {Mready = true; Layout parameters for forms Windowmanager.layoutparams LP = new Windowmanager.layoutparams (layoutparams.wrap_content, La Youtparams.wrap_content, WindowManager.LayoutParams.TYPE_APPLICATION, WindowManager.LayoutParams.FLAG_NOT_TOUC hable |
        WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE, pixelformat.translucent);
      Add TextView to the form Mwindowmanager.addview (MDIALOGTEXT, LP);
  }
    });
  }//Set visibilitypublic void Setmready (Boolean mready) {this.mready = Mready; /** * Generally used in the Onscroll method, the argument is a string, cannot be empty, takes the first character to display * @param prevletter/public void Showprevletter (string prevle
    tter) {if (!mready) {return;
    } Char firstletter = Prevletter.charat (0);
      if (!mshowing && firstletter!= mprevletter) {mshowing = true;
    Mdialogtext.setvisibility (view.visible);
    }//Set TextView display Font Mdialogtext.settext ((Character) firstletter). toString ());
    Removing the Runnable interface class Mhandler.removecallbacks (Mremovewindow) implemented by Mremovewindow;
    Add the Runnable interface class implemented by Mremovewindow, and set the delay mhandler.postdelayed (Mremovewindow, Delayed_hiden);
  Mprevletter = Firstletter; /** * Implements the Runnable interface class * * Private Final class Removewindow implements Runnable {public void run () {R
    Emovewindow ();
      } private void Removewindow () {if (mshowing) {mshowing = false;
    Mdialogtext.setvisibility (view.invisible);

 }
  }
}

The following is an XML file:

<?xml version= "1.0" encoding= "Utf-8"?> <textview xmlns:android=
"http://schemas.android.com/apk/res/" Android "
  android:textsize=" 50sp "
  android:textcolor=" "@color/band_common_content"
  android:background = "@drawable/common_list_title"
  android:minwidth= "70dip"
  android:layout_height= "Wrap_content
  " android:padding= "5dip"
  android:gravity= "center"
/>

More interested readers of Android content can view this site: "The activity of Android programming skills Summary", "Android File Operation skills Summary", "Android programming development of SD card operation method Summary", " Android Development Primer and Advanced tutorials, Android Resource operations tips, Android View overview and Android Control Usage summary

I hope this article will help you with the Android program.

Related Article

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.