An array of Android resource files (string, int)

Source: Internet
Author: User
<span id="Label3"></p><pre><span style="color: #008080;">1<span style="color: #008000;">/**<span style="color: #008080;">2<span style="color: #008000;">* String array<span style="color: #008080;">3<span style="color: #008000;">*/<span style="color: #008080;">4<span style="color: #0000ff;">Private<span style="color: #000000;">string[] dirstring;<span style="color: #008080;">5<span style="color: #008080;">6<span style="color: #008000;">/**<span style="color: #008080;">7<span style="color: #008000;">* Image Resource ID array<span style="color: #008080;">8<span style="color: #008000;">*/<span style="color: #008080;">9<span style="color: #0000ff;">Private<span style="color: #0000ff;">Int<span style="color: #000000;">[] dirint;<span style="color: #008080;">10<span style="color: #008080;">11<span style="color: #000000;">@Override<span style="color: #008080;">12<span style="color: #0000ff;">Protected<span style="color: #0000ff;">void<span style="color: #000000;">OnCreate (Bundle Savedinstancestate) {<span style="color: #008080;">13<span style="color: #0000ff;">Super<span style="color: #000000;">. onCreate (savedinstancestate);<span style="color: #008080;">Resources res =<span style="color: #000000;">Getresources ();<span style="color: #008080;">Dirstring =<span style="color: #000000;"><span style="color: #000000;"> Res.getstringarray (r.array.dir_string); <span style="color: #008080;">16 <span style="color: #008080;">17 TypedArray Tarr =<span style="color: #000000;"> Res.obtaintypedarray (r.array.dir_image); <span style="color: #008080;">18 <span style="color: #0000ff;">int len =<span style="color: #000000;"> tarr.length (); <span style="color: #008080;">19 dirint = <span style="color: #0000ff;">new <span style="color: #0000ff;">int<span style="color: #000000;">[len]; <span style="color: #008080;">20 <span style="color: #0000ff;">for (<span style="color: #0000ff;">int i = 0; i < Len I ++<span style="color: #008080;" ) {<span>21 dirint[i] = Tarr.getresourceid (i, 0<span style="color: #000000;">); <span style="color: #008080;">22 <span style="color: #000000;">}<span style="color: #008080;">23} </span> </span> </span> </span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span> </span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></pre><p><p>The array dirstring stores the resource itself (sring type of data), and the array Dirint stores the ID of the RESOURCE.</p></p><pre><pre><span style="color: #008080;">1</span> <span style="color: #000000;">Textview.settext (dirstring[index]);</span> <span style="color: #008080;">2</span> <span style="color: #008080;">3</span> Imageview.setimageresource (dirint[index]);</pre></pre><p><p>Using the code snippet above, the type of TextView is textview, and the ImageView type is IMAGEVIEW.</p></p><p><p>An array of Android resource files (string, int)</p></p></span>

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.