<div class="table_wrap" style="margin: 0px; padding: 0px; overflow: auto; color: #303030; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, sans-serif; font-size: 16px; background-color: #ffffff;">
   <table class="MsoTableMediumGrid1Accent1" cellspacing="0" cellpadding="0" border="1" style="border-spacing: 0px; word-break: normal; border-width: medium; border-style: none; border-color: initial;">
      <tbody>
         <tr style="height: 23.25pt;">
            <td width="615" style="margin: 0px; padding: 0cm 5.4pt; font-size: 14px; line-height: 1.5; border-width: 1pt; border-style: solid; border-color: #7ba0cd; background: rgb(211, 223, 238); width: 461.2pt; height: 23.25pt;">
               <p class="MsoNormal" align="center" style="margin: 0cm 0cm 0pt; padding: 0px; text-align: center;"><b><font size="2"><font color="#000000"><font face="맑은 고딕"><span lang="EN-US">android&nbsp;</span>특정 위치에 위젯 클릭시 색상 변환<span lang="EN-US"><o:p></o:p></span></font></font></font></b></p>
               </td>
            </tr>
         </tbody>
      </table>
   </div>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; padding: 0px; color: #303030; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, sans-serif; font-size: 16px; background-color: #ffffff;"><span lang="EN-US"><o:p><font face="맑은 고딕" color="#000000" size="2">&nbsp;</font></o:p></span></p>
<div class="table_wrap" style="margin: 0px; padding: 0px; overflow: auto; color: #303030; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, sans-serif; font-size: 16px; background-color: #ffffff;">
   <table class="MsoTableLightGridAccent1" cellspacing="0" cellpadding="0" border="1" style="border-spacing: 0px; word-break: normal; border-width: medium; border-style: none; border-color: initial;">
      <tbody>
         <tr>
            <td valign="top" width="615" style="margin: 0px; padding: 0cm 5.4pt; font-size: 14px; line-height: 1.5; border-width: 1pt 1pt 2.25pt; border-style: solid; border-color: #4f81bd; width: 461.2pt; background-color: transparent;">
               <p class="MsoNormal" style="margin: 0cm 0cm 0pt; padding: 0px;"><b><span style="font-size: 11pt;"><font color="#000000"><font face="맑은 고딕">개발환경<span lang="EN-US">&nbsp;: JDK 6.0, android API 2.2, window XP<o:p></o:p></span></font></font></span></b></p>
               </td>
            </tr>
         </tbody>
      </table>
   </div>
<p><br style="color: #303030; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, sans-serif; font-size: 16px; background-color: #ffffff;" /></p>
<div class="imageblock center" style="margin: 0px; padding: 0px; color: #303030; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, sans-serif; font-size: 16px; background-color: #ffffff; text-align: center; clear: both;"><img src="https://img1.daumcdn.net/thumb/R720x0.q80/?scode=mtistory&amp;fname=http%3A%2F%2Fcfile27.uf.tistory.com%2Fimage%2F163B271F4CF8695E19A7F4" class="img_thumb" style="border: 0px none; vertical-align: top; display: inline; max-width: 100%; height: auto; margin: 0px auto 10px;" /></div>
<p><br style="color: #303030; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, sans-serif; font-size: 16px; background-color: #ffffff;" /></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; padding: 0px; color: #303030; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, sans-serif; font-size: 16px; background-color: #ffffff;"><font size="2"><font color="#000000"><font face="맑은 고딕">여러개의 데이타를 표현하고자 할때 행으로 된 리스트를 보여주게 된다<span lang="EN-US">.</span></font></font></font></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; padding: 0px; color: #303030; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, sans-serif; font-size: 16px; background-color: #ffffff;"><font face="맑은 고딕" color="#000000" size="2">안드로이드에서는<span lang="EN-US">&nbsp;ArrayAdapter, ListView&nbsp;</span>를 상속받아 사용자정의 클래스를</font></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; padding: 0px; color: #303030; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, sans-serif; font-size: 16px; background-color: #ffffff;"><font size="2"><font color="#000000"><font face="맑은 고딕">만들어 리스트 데이타를 표현하기도 하고<span lang="EN-US">, LayoutInflater&nbsp;</span>객체로<span lang="EN-US">&nbsp;addView</span></font></font></font></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; padding: 0px; color: #303030; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, sans-serif; font-size: 16px; background-color: #ffffff;"><font size="2"><font color="#000000"><font face="맑은 고딕">함수를 사용해 미리 정의된 행자체를 추가할수도 있다<span lang="EN-US">.</span></font></font></font></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; padding: 0px; color: #303030; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, sans-serif; font-size: 16px; background-color: #ffffff;"><font size="2"><font color="#000000"><font face="맑은 고딕">리스트를 만드는 방법은 다양하므로 자기가 편한 방법을 취사 선택하면<span lang="EN-US"></span></font></font></font></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; padding: 0px; color: #303030; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, sans-serif; font-size: 16px; background-color: #ffffff;"><font size="2"><font color="#000000"><font face="맑은 고딕">될것같다<span lang="EN-US">.&nbsp;</span>여기에서는 위해서 언급한 두가지 경우에 따라 클릭시<span lang="EN-US"></span></font></font></font></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; padding: 0px; color: #303030; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, sans-serif; font-size: 16px; background-color: #ffffff;"><font size="2"><font color="#000000"><font face="맑은 고딕">색상 변환을 어떻게 처리할지 간단하게 다루도록 한다<span lang="EN-US">.</span></font></font></font></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; padding: 0px; color: #303030; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, sans-serif; font-size: 16px; background-color: #ffffff;"><span lang="EN-US"><o:p><font face="맑은 고딕" color="#000000" size="2">&nbsp;</font></o:p></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; padding: 0px; color: #303030; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, sans-serif; font-size: 16px; background-color: #ffffff;"><font size="2"><font color="#000000"><font face="맑은 고딕">첫번째&nbsp;<span lang="EN-US">ListView&nbsp;</span>를 상속받아 만들었다면 내장함수&nbsp;<span lang="EN-US">setOnItemClickListener&nbsp;</span>를<span lang="EN-US"></span></font></font></font></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; padding: 0px; color: #303030; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, sans-serif; font-size: 16px; background-color: #ffffff;"><font size="2"><font color="#000000"><font face="맑은 고딕">셋팅해서 사용하면 된다<span lang="EN-US">. setOnItemClickListener&nbsp;</span>에 인자로 들어가는<span lang="EN-US"></span></font></font></font></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; padding: 0px; color: #303030; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, sans-serif; font-size: 16px; background-color: #ffffff;"><font size="2"><font color="#000000"><font face="맑은 고딕"><span lang="EN-US">OnItemClickListener&nbsp;</span>클래스의&nbsp;<span lang="EN-US">onItemClick&nbsp;</span>함수를 오버라이딩해서 그 내부에<span lang="EN-US"></span></font></font></font></p>
<p><span style="font-size: 10pt; color: #303030; background-color: #ffffff; font-family: &quot;맑은 고딕&quot;;"><font color="#000000">색깔 변경 관련 소스를 집어넣는다<span lang="EN-US">.</span></font></span></p>
<pre class="brush:java hljs" name="code" style="margin-top: 0px; overflow: auto; color: #383a42; background: rgb(248, 248, 248); font-size: 14px; line-height: 27px; margin-bottom: 20px !important; padding: 13px 20px !important;"><span class="hljs-keyword" style="color: #a626a4;">private</span><span class="hljs-class"><span class="hljs-keyword" style="color: #a626a4;">class</span><span class="hljs-title" style="color: #c18401;">MyListView</span><span class="hljs-keyword" style="color: #a626a4;">extends</span><span class="hljs-title" style="color: #c18401;">ListView</span></span>{
       <span class="hljs-keyword" style="color: #a626a4;">private</span> String[] mStrings = {<span class="hljs-string" style="color: #50a14f;">"1번째"</span>, <span class="hljs-string" style="color: #50a14f;">"1번째"</span>, <span class="hljs-string" style="color: #50a14f;">"3번째"</span>, <span class="hljs-string" style="color: #50a14f;">"4번째"</span>};
       <span class="hljs-function"><span class="hljs-keyword" style="color: #a626a4;">public</span><span class="hljs-title" style="color: #4078f2;">MyListView</span><span class="hljs-params">(Context context)</span></span>{
           <span class="hljs-keyword" style="color: #a626a4;">super</span>(context);
           listView();
       }
       <span class="hljs-function"><span class="hljs-keyword" style="color: #a626a4;">public</span><span class="hljs-keyword" style="color: #a626a4;">void</span><span class="hljs-title" style="color: #4078f2;">listView</span><span class="hljs-params">()</span></span>{
           setAdapter(<span class="hljs-keyword" style="color: #a626a4;">new</span> ArrayAdapter<string> (getContext(), android.R.layout.simple_list_item_1, mStrings));
           setTextFilterEnabled(<span class="hljs-keyword" style="color: #a626a4;">true</span>);
           setOnItemClickListener(<span class="hljs-keyword" style="color: #a626a4;">new</span> OnItemClickListener() {
               <span class="hljs-meta" style="color: #4078f2;">@Override</span><span class="hljs-function"><span class="hljs-keyword" style="color: #a626a4;">public</span><span class="hljs-keyword" style="color: #a626a4;">void</span><span class="hljs-title" style="color: #4078f2;">onItemClick</span><span class="hljs-params">(AdapterView arg0, View arg1, <span class="hljs-keyword" style="color: #a626a4;">int</span> arg2, <span class="hljs-keyword" style="color: #a626a4;">long</span> arg3)</span></span>{
                   arg1.setBackgroundColor(Color.RED);
               }
           });
       }
   }</string></pre>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; padding: 0px; color: #303030; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, sans-serif; font-size: 16px; background-color: #ffffff;"><font face="맑은 고딕" color="#000000" size="2">두번째는&nbsp;<span lang="EN-US">ArrayAdapter&nbsp;</span>을 사용해서 색상을 변경하고자 할때이다<span lang="EN-US">. ArrayAdapter&nbsp;</span>에서는</font></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; padding: 0px; color: #303030; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, sans-serif; font-size: 16px; background-color: #ffffff;"><font size="2"><font color="#000000"><font face="맑은 고딕"><span lang="EN-US">getView&nbsp;</span>함수내부에 기능을 구현하게 되는데<span lang="EN-US">&nbsp;getView&nbsp;</span>에서 넘어오는 데이타는<span lang="EN-US"></span></font></font></font></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; padding: 0px; color: #303030; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, sans-serif; font-size: 16px; background-color: #ffffff;"><font size="2"><font color="#000000"><font face="맑은 고딕">리스트뷰에서 한 행을 의미한다<span lang="EN-US">.&nbsp;</span>한 행 전체의&nbsp;<span lang="EN-US">View&nbsp;</span>가 넘어오는 것이다<span lang="EN-US">.</span></font></font></font></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; padding: 0px; color: #303030; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, sans-serif; font-size: 16px; background-color: #ffffff;"><font face="맑은 고딕" color="#000000" size="2">그래서 한행 전체를 변경하고 싶을때는 두번째 인자로 넘어온<span lang="EN-US">&nbsp;convertView&nbsp;</span>를</font></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; padding: 0px; color: #303030; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, sans-serif; font-size: 16px; background-color: #ffffff;"><font size="2"><font color="#000000"><font face="맑은 고딕">사용하면 되고 그 행에서 특정<span lang="EN-US">&nbsp;View&nbsp;</span>의 상태를 변경하고자 할때는<span lang="EN-US"></span></font></font></font></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; padding: 0px; color: #303030; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, sans-serif; font-size: 16px; background-color: #ffffff;"><font size="2"><font color="#000000"><font face="맑은 고딕"><span lang="EN-US">TextView txtVicRank = (TextView) convertView.findViewById(R.id.vic_rank);&nbsp;</span>식으로<span lang="EN-US"></span></font></font></font></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; padding: 0px; color: #303030; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, sans-serif; font-size: 16px; background-color: #ffffff;"><font size="2"><font color="#000000"><font face="맑은 고딕">추출해서 사용하면 된다<span lang="EN-US">.</span></font></font></font></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; padding: 0px; color: #303030; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, sans-serif; font-size: 16px; background-color: #ffffff;"><font size="2"><font color="#000000"><font face="맑은 고딕">일단<span lang="EN-US">&nbsp;View&nbsp;</span>객체가 있다면 클릭이벤트를 추가해야하는데 그 함수는&nbsp;<span lang="EN-US">setOnTouchListener</span></font></font></font></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; padding: 0px; color: #303030; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, sans-serif; font-size: 16px; background-color: #ffffff;"><font face="맑은 고딕" color="#000000" size="2">이다<span lang="EN-US">.&nbsp;</span>인자로<span lang="EN-US">&nbsp;OnTouchListener&nbsp;</span>객체를 넘기게 되는데 내부에<span lang="EN-US">&nbsp;onTouch&nbsp;</span>함수를 구현 하면</font></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; padding: 0px; color: #303030; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, sans-serif; font-size: 16px; background-color: #ffffff;"><font size="2"><font color="#000000"><font face="맑은 고딕">된다<span lang="EN-US">.</span></font></font></font></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; padding: 0px; color: #303030; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, sans-serif; font-size: 16px; background-color: #ffffff;"><font face="맑은 고딕" color="#000000" size="2">소스를 간략하게 설명하자면 중간에<span lang="EN-US">&nbsp;setOnTouchListener&nbsp;</span>와 그 내부에<span lang="EN-US">&nbsp;onTouch&nbsp;</span>가 있다</font></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; padding: 0px; color: #303030; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, sans-serif; font-size: 16px; background-color: #ffffff;"><font size="2"><font color="#000000"><font face="맑은 고딕">인자로 넘어오는<span lang="EN-US">&nbsp;MotionEvent&nbsp;</span>를 통해 어떤 이벤트가 실행되었는지 판단하고<span lang="EN-US"></span></font></font></font></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; padding: 0px; color: #303030; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, sans-serif; font-size: 16px; background-color: #ffffff;"><font size="2"><font color="#000000"><font face="맑은 고딕">그에 합당한 기능을 집어 넣으면 된다<span lang="EN-US">.&nbsp;</span>소스에서는 클릭다운과 업일때 각각<span lang="EN-US"></span></font></font></font></p>
<p><span style="font-size: 10pt; color: #303030; background-color: #ffffff; font-family: &quot;맑은 고딕&quot;;"><font color="#000000">색상을 달리하는 기능을 넣었다<span lang="EN-US">.</span></font></span></p>
<pre class="brush:java hljs aspectj" name="code" style="margin-top: 0px; overflow: auto; color: #383a42; background: rgb(248, 248, 248); font-size: 14px; line-height: 27px; margin-bottom: 20px !important; padding: 13px 20px !important;"><span class="hljs-keyword" style="color: #a626a4;">private</span><span class="hljs-class"><span class="hljs-keyword" style="color: #a626a4;">class</span><span class="hljs-title" style="color: #c18401;">GameAdapter</span><span class="hljs-keyword" style="color: #a626a4;">extends</span><span class="hljs-title" style="color: #c18401;">ArrayAdapter</span></span><jsonobject><span class="hljs-class"></span>{
    <span class="hljs-keyword" style="color: #a626a4;">private</span> ArrayList<jsonobject> items;
    <span class="hljs-function"><span class="hljs-keyword" style="color: #a626a4;">public</span><span class="hljs-title" style="color: #4078f2;">GameAdapter</span><span class="hljs-params">(Context context, <span class="hljs-keyword" style="color: #a626a4;">int</span> textViewResourceId, ArrayList</span></span><jsonobject><span class="hljs-function"><span class="hljs-params"> items)</span></span>{
    	<span class="hljs-keyword" style="color: #a626a4;">super</span>(context, textViewResourceId, items);
        <span class="hljs-keyword" style="color: #a626a4;">this</span>.items = items;
    }
    <span class="hljs-comment" style="color: #a0a1a7; font-style: italic;">/* (non-Javadoc)
     * @see android.widget.ArrayAdapter#getCount()
     */</span><span class="hljs-keyword" style="color: #a626a4;">public</span><span class="hljs-function"><span class="hljs-keyword" style="color: #a626a4;">int</span><span class="hljs-title" style="color: #4078f2;">getCount</span><span class="hljs-params">()</span></span>{
        <span class="hljs-function"><span class="hljs-keyword" style="color: #a626a4;">return</span> items.<span class="hljs-title" style="color: #4078f2;">size</span><span class="hljs-params">()</span></span>;
    }
    <span class="hljs-meta" style="color: #4078f2;">@Override</span><span class="hljs-keyword" style="color: #a626a4;">public</span><span class="hljs-function">View <span class="hljs-title" style="color: #4078f2;">getView</span><span class="hljs-params">(<span class="hljs-keyword" style="color: #a626a4;">int</span> position, View convertView, ViewGroup parent)</span></span>{
        View v = convertView;
        <span class="hljs-keyword" style="color: #a626a4;">if</span> (v == <span class="hljs-keyword" style="color: #a626a4;">null</span>) {
            LayoutInflater vi = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            v = vi.inflate(R.layout.rigrank_soccer_sub, <span class="hljs-keyword" style="color: #a626a4;">null</span>);
        }
        <span class="hljs-comment" style="color: #a0a1a7; font-style: italic;">// 클릭했을때 표현 </span>
        v.setOnTouchListener(<span class="hljs-keyword" style="color: #a626a4;">new</span> OnTouchListener(){
			<span class="hljs-keyword" style="color: #a626a4;">public</span><span class="hljs-function"><span class="hljs-keyword" style="color: #a626a4;">boolean</span><span class="hljs-title" style="color: #4078f2;">onTouch</span><span class="hljs-params">(View v, MotionEvent event)</span></span>{
				<span class="hljs-keyword" style="color: #a626a4;">if</span>(event.getAction() == MotionEvent.ACTION_DOWN) {
					v.setBackgroundColor(<span class="hljs-number" style="color: #986801;">0xB6492600</span>);
				}<span class="hljs-keyword" style="color: #a626a4;">else</span><span class="hljs-keyword" style="color: #a626a4;">if</span>(event.getAction() == MotionEvent.ACTION_UP) {
					v.setBackgroundColor(<span class="hljs-number" style="color: #986801;">0x00000000</span>); <span class="hljs-comment" style="color: #a0a1a7; font-style: italic;">// 원래대로 복귀</span>
				}
				<span class="hljs-keyword" style="color: #a626a4;">return</span><span class="hljs-keyword" style="color: #a626a4;">false</span>;
			}
		});
        JSONObject p = items.get(position);
        <span class="hljs-keyword" style="color: #a626a4;">if</span> (p != <span class="hljs-keyword" style="color: #a626a4;">null</span>) {
        	TextView txtVicRank = (TextView) v.findViewById(R.id.vic_rank);
           	txtVicRank.setText(<span class="hljs-string" style="color: #50a14f;">"rank"</span>);
        }
        <span class="hljs-keyword" style="color: #a626a4;">return</span> v;
    }
}</jsonobject></jsonobject></jsonobject></pre>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; padding: 0px; color: #303030; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, sans-serif; font-size: 16px; background-color: #ffffff;"><font size="2"><font color="#000000"><font face="맑은 고딕">세번째는&nbsp;<span lang="EN-US">LinearLayout&nbsp;</span>를 통해서 리스트를 만드는 경우인데 리스트를 표현하는<span lang="EN-US"></span></font></font></font></p>
<p><span style="font-size: 10pt; color: #303030; background-color: #ffffff; font-family: &quot;맑은 고딕&quot;;"><font color="#000000">방식이 틀릴뿐 클릭이벤트 처리부분은 두번째와 동일하다</font></span></p>
<pre class="brush:java hljs cs" name="code" style="margin-top: 0px; overflow: auto; color: #383a42; background: rgb(248, 248, 248); font-size: 14px; line-height: 27px; margin-bottom: 20px !important; padding: 13px 20px !important;">LinearLayout mList = (LinearLayout)mVi.inflate(R.layout.rigrank_soccer_sub, mGeneral, <span class="hljs-literal" style="color: #0184bb;">false</span>);
JSONObject p = mReceiveData.getJSONObject(i);
<span class="hljs-keyword" style="color: #a626a4;">if</span> (p != <span class="hljs-literal" style="color: #0184bb;">null</span>) {
	<span class="hljs-keyword" style="color: #a626a4;">try</span> {
    	TextView txtVicRank = (TextView) mList.findViewById(R.id.vic_rank);
        TextView txtTeamName = (TextView) mList.findViewById(R.id.team_name);
        String teamNo = p.getString(<span class="hljs-string" style="color: #50a14f;">"TEAM_NO"</span>);
        txtTeamName.setId(Integer.parseInt(teamNo));
        txtTeamName.setOnClickListener(<span class="hljs-keyword" style="color: #a626a4;">new</span> OnClickListener() {
			<span class="hljs-comment" style="color: #a0a1a7; font-style: italic;">/** 상세화면으로 보낸다 */</span><span class="hljs-function"><span class="hljs-keyword" style="color: #a626a4;">public</span><span class="hljs-keyword" style="color: #a626a4;">void</span><span class="hljs-title" style="color: #4078f2;">onClick</span>(<span class="hljs-params">View v</span>) </span>{
            	<span class="hljs-comment" style="color: #a0a1a7; font-style: italic;">// 팀번호를 상세화면으로 보낸다</span>
            	LogManager.d(<span class="hljs-keyword" style="color: #a626a4;">this</span>.getClass().getName(), <span class="hljs-string" style="color: #50a14f;">"Data Number : "</span> + v.getId());
            	Intent intent = <span class="hljs-keyword" style="color: #a626a4;">new</span> Intent(mContext, TeamInfo.class);
				intent.putExtra(<span class="hljs-string" style="color: #50a14f;">"teamNo"</span>, String.valueOf(v.getId()));
				startActivity(intent);
            }
        });
        <span class="hljs-comment" style="color: #a0a1a7; font-style: italic;">// 클릭했을때 표현 </span>
        txtTeamName.setOnTouchListener(<span class="hljs-keyword" style="color: #a626a4;">new</span> OnTouchListener(){
			<span class="hljs-function"><span class="hljs-keyword" style="color: #a626a4;">public</span> boolean <span class="hljs-title" style="color: #4078f2;">onTouch</span>(<span class="hljs-params">View v, MotionEvent <span class="hljs-keyword" style="color: #a626a4;">event</span></span>) </span>{
				<span class="hljs-keyword" style="color: #a626a4;">if</span>(<span class="hljs-keyword" style="color: #a626a4;">event</span>.getAction() == MotionEvent.ACTION_DOWN) {
					v.setBackgroundColor(<span class="hljs-number" style="color: #986801;">0xB6492600</span>);
				}<span class="hljs-keyword" style="color: #a626a4;">else</span><span class="hljs-keyword" style="color: #a626a4;">if</span>(<span class="hljs-keyword" style="color: #a626a4;">event</span>.getAction() == MotionEvent.ACTION_UP) {
					v.setBackgroundColor(<span class="hljs-number" style="color: #986801;">0x00000000</span>); <span class="hljs-comment" style="color: #a0a1a7; font-style: italic;">// 원래대로 복귀</span>
				}
				<span class="hljs-keyword" style="color: #a626a4;">return</span><span class="hljs-literal" style="color: #0184bb;">false</span>;
			}
		});
	} <span class="hljs-keyword" style="color: #a626a4;">catch</span> (JSONException e) {
		e.printStackTrace();
	}
}
mGeneral.addView(mList);</pre>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; padding: 0px; color: #303030; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, sans-serif; font-size: 16px; background-color: #ffffff;"><font size="2"><font color="#000000"><font face="맑은 고딕">상단에 있는 안드로이드 화면은 클릭시 색상이 변경되는 모습을 캡쳐한 것이다<span lang="EN-US">.</span></font></font></font></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; padding: 0px; color: #303030; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, sans-serif; font-size: 16px; background-color: #ffffff;"><font size="2"><font color="#000000"><font face="맑은 고딕">그리고 세번째 소스로 구현한 것이다<span lang="EN-US">. View&nbsp;</span>에 보면<span lang="EN-US">&nbsp;setOn&nbsp;</span>으로 시작하는 함수가<span lang="EN-US"></span></font></font></font></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; padding: 0px; color: #303030; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, sans-serif; font-size: 16px; background-color: #ffffff;"><font size="2"><font color="#000000"><font face="맑은 고딕">여러개 있다<span lang="EN-US">.&nbsp;</span>이벤트에 대한 구현인데&nbsp;<span lang="EN-US">setOnFocusChangeListener(l),&nbsp;&nbsp;&nbsp;setOnKeyListener(l)</span></font></font></font></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; padding: 0px; color: #303030; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, sans-serif; font-size: 16px; background-color: #ffffff;"><font size="2"><font color="#000000"><font face="맑은 고딕"><span lang="EN-US">setOnTouchListener(l)&nbsp;</span>등이있다<span lang="EN-US">.&nbsp;</span>이름에서도 알수 있듯이 포커스가 갔을때 어떤 키를</font></font></font></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; padding: 0px; color: #303030; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, sans-serif; font-size: 16px; background-color: #ffffff;"><font size="2"><font color="#000000"><font face="맑은 고딕">눌렸느냐 등인데 이 함수를 사용하면 위젯의 다양한 이벤트를 활용해서<span lang="EN-US"></span></font></font></font></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; padding: 0px; color: #303030; font-family: &quot;Apple SD Gothic Neo&quot;, &quot;Malgun Gothic&quot;, &quot;맑은 고딕&quot;, sans-serif; font-size: 16px; background-color: #ffffff;"><font size="2"><font color="#000000"><font face="맑은 고딕">좀더 생동감 있는 어플을 구현할수 있지 않을까<span lang="EN-US">?</span></font></font></font></p>