How to display images and images in textview of Android

Source: Internet
Author: User

The implementation result is as follows: (thanks to the explanation from the old Luo video) Video: click here

It's okay to look at different implementation schemes. Displays nested dot images in textview. Good results. Some people should say that you are so stupid and will use it for a while. Haha. In fact, this method can avoid confusion and nesting in the layout. You only need to create a textview and copy the image into the drawable folder to implement some functions. It does not need to be so troublesome. Otherwise, it would be difficult to embed a lot of la S.

 

The Code is as follows:

Package lixiaodaoaaa.com. ui; import Java. lang. reflect. field; import android. app. activity; import android. graphics. color; import android. graphics. drawable. drawable; import android. OS. bundle; import android. text. HTML; import android. text. HTML. imagegetter; import android. widget. textview;/*** by lixiaodaoaaa tecent_weibo: http://t.qq.com/lixiaodaoaaa * xinlang_weibo: http://weibo.com/lixiaodaoaaa ** @ author Lixiaodaoaaa **/public class mainactivity extends activity {/*** This method uses the resource name to compare the resource idleness to the face_01.png ID under the drawablefolder; * mainly uses R. drawable. class. getfield uses the reflection method. ** @ Param name * @ return */Public int gerresouceidbyname (string name) {try {field = R. drawable. class. getfield (name); Return integer. parseint (field. get (null ). tostring ();} catch (exception e) {system. out. println ("parse fialed return 0 is here");} return 0 ;}@ overridepublic void oncreate (bundle savedinstancestate) {super. oncreate (savedinstancestate); setcontentview (R. layout. activity_main); inittextvie W ();} private void inittextview () {textview = (textview) findviewbyid (R. id. TV _test01); textview. setbackgroundcolor (color. white); textview. settextcolor (color. black); textview. settextsize (20); string html1 = "Image 1  <p> "; html1 + = "Image 2  <p> "; html1 + = "Image 3  <p>"; // <p> here is the section mark. Let him display the text below the line break; html1 + = "Image 4 <a href = 'HTTP: // weibo.com/lixiaodaoaaa'>  </a> <p> "; html1 + = "image 5 

Source code: Click here to download

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.