Android Scaling Control Expandablelistview the possible cause of the expansion failure.

Source: Internet
Author: User
<span id="Label3"></p><p><p><span style="font-size: 14pt;">(original) Reprint Please declare the source http://www.cnblogs.com/linguanh/</span></p></p><p><p></p></p><p><p><span style="font-size: 14pt;">Problem Prototypes:</span></p></p><p><p><span style="font-size: 14pt;">Expandablelistview Expansion Failure.</span></p></p><p><p></p></p><p><p><span style="font-size: 14pt;">-------------------- <span style="color: #ff0000;">look directly at the conclusion, please pull the Red line <span style="color: #000000;">-------------------</span> </span></span></p></p><p><p><span style="font-size: 14pt;">As early as May, I wrote a post on a custom Expandablelistview contract, and I didn't have this problem at the Time.</span></p></p><p><p><span style="font-size: 14pt;">everything went well,</span> <span style="font-size: 14pt;"></span> <span style="font-size: 14pt;">entrance: http://www.cnblogs.com/linguanh/p/4521257.html</span></p></p><p><p><span style="font-size: 14pt;"></span></p></p><p><p><span style="font-size: 14pt;"></span></p></p><p><p>To this day, I would like to <span style="font-size: 14pt;">make a schedule, considering the month is optional, so you want to re-use expandablelistview, use it. </span> <span style="font-size: 14pt; line-height: 1.5;">We know that using Expandablelistview to configure the data for it is a configurator, that is, expandablelistadapter, which has 9 interface functions that require rewriting, specifically go to my profile to learn about It:/http Www.cnblogs.com/linguanh/p/4521257.html</span></p></p><p><p></p></p><p><p><span style="font-size: 14pt;">One of them is:</span></p></p><pre><pre><span style="color: #008080;">1</span> <span style="color: #000000;">@Override</span> <span style="color: #008080;">2</span> <span style="color: #0000ff;"></span> public View Getgroupview (<span style="color: #0000ff;">int</span><span style="color: #0000ff;">boolean</span> isexpanded, view convertview, viewgroup Parent)</pre></pre><p><p><span style="font-size: 14pt;">its role is to let us return to the view of the first level directory, usually using</span> <span style="font-size: 14pt; font-family: verdana, Arial, Helvetica, sans-serif; line-height: 1.5;">one of the five major layouts, such as:</span></p></p><pre><pre> <span style="font-size:18px;">linearlayout Group = (linearlayout) relativelayout.inflate (context, r.layout. layout, null); </span> <br> <br> <br> <span style="font-size:14pt;"> we're in </span> <span style="font-size:18px;">getgroupview </span> <span style="font-size:14pt;" the function returns this view,<span style="color: #ff0000;"> Note </span>: inside <span style="font-size:18px;">r.layout. layout </span> <span style="font-size:14pt;"> is our custom One-level directory XML layout <br> file, and That's where I'm going to go. <br> <br> After I have determined that the code is not a problem, the point is running, a few seconds later, Getgroupview loaded the first level of the directory XML layout display, ok, very good, and then I clicked, point to find, sister's, did not expand two level directory. Then go back to the fart to find the bug, the code is ok, so added a lot of log, run again, view the log. I'll Take a walk! <br> </span> </pre></pre><pre><pre><span style="color: #008080;">1</span><span style="color: #000000;"></span><span style="color: #008080;">2</span><span style="color: #0000ff;"></span> public View getchildview (<span style="color: #0000ff;">int</span><span style="color: #0000ff;">int</span><span style="color: #0000ff;">boolean</span> islastchild, View convertview, ViewGroup Parent)</pre></pre><pre><pre></pre></pre><pre><pre>the <span style="font-size: 14pt;"> shipment was not executed and the log was not Printed. So subconsciously I looked at</span> the XML layout I introduced in <span class="cnblogs_code">Getchildview</span> <span style="font-size: 14pt;">, and the first XML layout I said above was a one-level directory, in</span> <span class="cnblogs_code" style="line-height: 1.5;"></span> the <span style="font-size: 14pt;">layout of a level two directory. After viewing it, I couldn't find the reason for it to be wrong, so I was able to find the example XML file that I had successfully replaced, run, click, or not, then I fuck the Dog. </span></pre></pre><pre><pre><span style="font-size: 14pt;"> </span><span style="font-size: 18px;">Getgroupview</span> <span style="font-size: 14pt;">the introduction of the first level of the XML layout of the function, see still find the reason for error, ibid, with the previous successful replacement under, run, click, made, incredibly ok. Then I began to compare the original layout file and the replacement can Be.<br>Control type comparison difference: <span style="color: #ff0000;"></span> </span> <span style="font-size: 14pt;">control, can be no with button, the same as Elsewhere.<br><br> See this, suddenly feel, is not the Button's Click Property overrides the original level of the directory clickable properties? Then look at the width and height of the button, i.e.<br>Its effective click range, All is wrap, according to the reason does not occupy the entire Father view, I point other place, is not to point to it.<br>But that's the way it is. The presence of a button causes the Expandablelistview to fail at the click of a directory.<br>This is really a sinkhole, Baidu Baidu immediately, See if there is the same case, Baidu found, have encountered and I have the same problem, but there is no solution!!!<br>Mood a little excited, haha.<br><br><strong><span style="color: #ff0000;">---------------------------------------------------------</span></strong><br>Summarize:<br></span></pre></pre><pre><pre><span style="font-size: 14pt;">The custom first-level directory XML layout file that is introduced in the Getgroupview function in the Expandablelistview data adapter Expandablelistadapter cannot have a button, which causes the expansion to Fail. ImageButton never tried, but probably not.<br><br>Example Comparison:<br>Counter example, with a button<br></span></pre></pre><pre><span style="color: #008080;"><span style="color: #008080;">1</span></span> <span style="color: #0000ff;"><span style="color: #0000ff;"><?</span></span><span style="color: #ff00ff;"><span style="color: #ff00ff;">XML version= "1.0" encoding= "utf-8"</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">?></span></span><span style="color: #008080;"><span style="color: #008080;">2</span></span> <span style="color: #0000ff;"><span style="color: #0000ff;"><</span></span><span style="color: #800000;"><span style="color: #800000;">LinearLayout</span></span><span style="color: #ff0000;"><span style="color: #ff0000;">xmlns:android</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">= "http://schemas.android.com/apk/res/android"</span></span><span style="color: #008080;"><span style="color: #008080;">3</span></span> <span style="color: #ff0000;"><span style="color: #ff0000;">android:orientation</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">= "horizontal"</span></span><span style="color: #008080;"><span style="color: #008080;">4</span></span> <span style="color: #ff0000;"><span style="color: #ff0000;">Android:layout_width</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">= "match_parent"</span></span><span style="color: #008080;"><span style="color: #008080;">5</span></span> <span style="color: #ff0000;"><span style="color: #ff0000;">Android:layout_height</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">= "match_parent"</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">></span></span><span style="color: #008080;"><span style="color: #008080;">6</span></span> <span style="color: #008080;"><span style="color: #008080;">7</span></span> <span style="color: #0000ff;"><span style="color: #0000ff;"><</span></span><span style="color: #800000;"><span style="color: #800000;">ImageView</span></span><span style="color: #008080;"><span style="color: #008080;">8</span></span> <span style="color: #ff0000;"><span style="color: #ff0000;">Android:layout_marginleft</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">= "@dimen/extend_x_left"</span></span><span style="color: #008080;"><span style="color: #008080;">9</span></span> <span style="color: #ff0000;"><span style="color: #ff0000;">Android:id</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">= "@+id/entend_x"</span></span><span style="color: #008080;"><span style="color: #008080;">Ten</span></span> <span style="color: #ff0000;"><span style="color: #ff0000;">Android:background</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">= "@drawable/extend_x"</span></span><span style="color: #008080;"><span style="color: #008080;"></span> one</span> <span style="color: #ff0000;"><span style="color: #ff0000;">Android:layout_width</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">= "wrap_content"</span></span><span style="color: #008080;"><span style="color: #008080;"></span> a</span> <span style="color: #ff0000;"><span style="color: #ff0000;">Android:layout_height</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">= "wrap_content"</span></span> <span style="color: #0000ff;"><span style="color: #0000ff;">/></span></span><span style="color: #008080;"><span style="color: #008080;"></span> -</span> <span style="color: #0000ff;"><span style="color: #0000ff;"><</span></span><span style="color: #800000;"><span style="color: #800000;">TextView</span></span><span style="color: #008080;"><span style="color: #008080;"></span> -</span> <span style="color: #ff0000;"><span style="color: #ff0000;">Android:alpha</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">= "0.8"</span></span><span style="color: #008080;"><span style="color: #008080;"></span> the</span> <span style="color: #ff0000;"><span style="color: #ff0000;">Android:id</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">= "@+id/time_coustom"</span></span><span style="color: #008080;"><span style="color: #008080;"></span> -</span> <span style="color: #ff0000;"><span style="color: #ff0000;">Android:layout_marginleft</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">= "20dp"</span></span><span style="color: #008080;"><span style="color: #008080;"></span> -</span> <span style="color: #ff0000;"><span style="color: #ff0000;">Android:text</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">= "1:00pm"</span></span><span style="color: #008080;"><span style="color: #008080;"></span> -</span> <span style="color: #ff0000;"><span style="color: #ff0000;">android:textsize</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">= "17dp"</span></span><span style="color: #008080;"><span style="color: #008080;"></span> +</span> <span style="color: #ff0000;"><span style="color: #ff0000;">Android:layout_width</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">= "wrap_content"</span></span><span style="color: #008080;"><span style="color: #008080;"></span> -</span> <span style="color: #ff0000;"><span style="color: #ff0000;">Android:layout_height</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">= "wrap_content"</span></span><span style="color: #008080;"><span style="color: #008080;"></span> +</span> <span style="color: #0000ff;"><span style="color: #0000ff;">/></span></span><span style="color: #008080;"><span style="color: #008080;"></span> a</span> <span style="color: #0000ff;"><span style="color: #0000ff;"><</span></span><span style="color: #800000;"><span style="color: #800000;">Button</span></span><span style="color: #008080;"><span style="color: #008080;"></span> at</span> <span style="color: #ff0000;"><span style="color: #ff0000;">Android:id</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">= "@+id/down"</span></span><span style="color: #008080;"><span style="color: #008080;"></span> -</span> <span style="color: #ff0000;"><span style="color: #ff0000;">Android:layout_margintop</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">= "10dp"</span></span><span style="color: #008080;"><span style="color: #008080;"></span> -</span> <span style="color: #ff0000;"><span style="color: #ff0000;">Android:layout_marginright</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">= "10dp"</span></span><span style="color: #008080;"><span style="color: #008080;"></span> -</span> <span style="color: #ff0000;"><span style="color: #ff0000;">Android:background</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">= "@drawable/right"</span></span><span style="color: #008080;"><span style="color: #008080;"></span> -</span> <span style="color: #ff0000;"><span style="color: #ff0000;">Android:layout_width</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">= "15dp"</span></span><span style="color: #008080;"><span style="color: #008080;"></span> -</span> <span style="color: #ff0000;"><span style="color: #ff0000;">Android:layout_height</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">= "15dp"</span></span> <span style="color: #0000ff;"><span style="color: #0000ff;">/></span></span><span style="color: #008080;"><span style="color: #008080;"></span> in</span> <span style="color: #0000ff;"><span style="color: #0000ff;"></</span></span><span style="color: #800000;"><span style="color: #800000;">LinearLayout</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">></span></span></pre><p><p></p></p><p><p><span style="font-size: 14pt;">Feasible:</span></p></p><p><p><span style="font-size: 14pt;">The above code removes the button</span></p></p><pre><pre><span style="font-size: 14pt;"><br><br><br><br><br><br></span></pre></pre><pre><pre><span style="font-size: 14pt;"></span></pre></pre><pre><pre></pre></pre><pre><pre><em id="__mceDel"><span style="font-size: 14pt;"></span></em></pre></pre><p><p>Android Scaling Control Expandablelistview the possible cause of the expansion failure.</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.