importjava.util.ArrayList;
importandroid.app.Activity;
importandroid.content.Context;
importandroid.os.Bundle;
importandroid.util.AttributeSet;
importandroid.util.Log;
importandroid.view.LayoutInflater;
importandroid.view.View;
importandroid.view.ViewGroup;
importandroid.view.View.OnClickListener;
importandroid.widget.AdapterView;
importandroid.widget.ArrayAdapter;
importandroid.widget.CheckBox;
importandroid.widget.Checkable;
importandroid.widget.ImageView;
importandroid.widget.LinearLayout;
importandroid.widget.ListView;
importandroid.widget.TextView;
importandroid.widget.AdapterView.OnItemClickListener;
importcom.sec.android.touchwiz.samples.R;
publicclassListLayoutSample2XmlextendsActivity{
privatestaticfinalStringTAG="ListLayoutSample2Xml";
privateListViewmList;
privateCheckBoxmHeaderAllCheckBox;
privatefinalintAGENDA_NONE=0;
privatefinalintAGENDA_CYAN=1;
privatefinalintAGENDA_BLUE=2;
privatefinalintAGENDA_GREEN=3;
privatefinalintAGENDA_PURPLE=4;
privatefinalintAGENDA_YELLOW=5;
privatefinalintAGENDA_COBALT=6;
privatefinalintAGENDA_TAG_ICON_NONE=100;
privatefinalintAGENDA_TAG_ICON_GOOGLE=101;
privatefinalintAGENDA_TAG_ICON_FACEBOOK=102;
/**Calledwhentheactivityisfirstcreated.*/
@Override
publicvoidonCreate(BundlesavedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.listlayoutsample2xml_main);
mList=(ListView)findViewById(R.id.agendaAllList);
mList.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
Viewallitem=getLayoutInflater().inflate(R.layout.listlayoutsample2xml_allitem,null);
mHeaderAllCheckBox=(CheckBox)allitem.findViewById(R.id.allitemcheck);
//[09.10.23]newlyadded!!!allitemclickListenertosetcheckstatusofallitems.
allitem.setOnClickListener(newOnClickListener(){
publicvoidonClick(Viewview){
Log.d("allitemheader","onClick()");
mHeaderAllCheckBox.performClick();
}
});
mHeaderAllCheckBox.setOnClickListener(newOnClickListener(){
publicvoidonClick(Viewview){
Log.d("allitemheadercheckbox","onClick()");
CheckBoxcheckBox=(CheckBox)view;
booleanchecked=checkBox.isChecked();
setAllItemChecked(checked);
}
});
mList.addHeaderView(allitem);
mList.post(newRunnable(){
publicvoidrun(){
updateAllCheckState();
}
});
LayoutInflaterli=(LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
Viewallitem=li.inflate(R.layout.touchwiz3list2_allitem,null);
LinearLayoutallitem=(LinearLayout)findViewById(R.id.allitem);
allitem=newLinearLayout(this);
if(allitem==null)
Log.i("TouchWiz3List2","allitemviewisnull");
else
{
TextViewallitemtext=(TextView)findViewById(R.id.allitemtext);
allitemtext=newTextView(this);
CheckBoxallitemcheck=(CheckBox)findViewById(R.id.allitemcheck);
allitemcheck=newCheckBox(this);
allitemtext.setText("Allcalendar");
allitemtext.setTextSize(36);
allitemtext.setTextColor(Color.WHITE);
allitemtext.setPadding(20,allitemtext.getPaddingTop(),allitemtext.getPaddingRight(),allitemtext.getPaddingBottom());
allitem.setMinimumHeight(90);
allitem.setGravity(Gravity.CENTER_VERTICAL);
allitem.setBackgroundDrawable(getResources().getDrawable(R.drawable.winset_selectall_bg));
allitem.addView(allitemtext);
allitem.addView(allitemcheck);
agendaList.addHeaderView(allitem);
}
*/
//AgendaItemtype?item???ArrayList???
ArrayList<AgendaItem>list=newArrayList<AgendaItem>();
//mAgenda????for????ArrayList?itemadd
for(inti=0;i<mAgenda.length;i++){
AgendaItemcontact=newAgendaItem(mAgendaColor<wbr style="line-height:25px">,mAgendaTagIcon<wbr style="line-height:25px">,mAgenda<wbr style="line-height:25px">,mTag<wbr style="line-height:25px">);<br style="line-height:25px"> list.add(contact);<br style="line-height:25px"> }<br style="line-height:25px"><br style="line-height:25px"> //AgendaAdapter??<br style="line-height:25px"> AgendaAdapteragendaAdapter=newAgendaAdapter(this,R.layout.listlayoutsample2xml_row,list);<br style="line-height:25px"> //ListView?AgendaAdapter??<br style="line-height:25px"> mList.setAdapter(agendaAdapter);<br style="line-height:25px"><br style="line-height:25px"> mList.setOnItemClickListener(newOnItemClickListener(){<br style="line-height:25px"> publicvoidonItemClick(AdapterView<?>parent,Viewview,<br style="line-height:25px"> intposition,longid){<br style="line-height:25px"> Log.d(TAG,"onItemClick("+position+")");<br style="line-height:25px"><br style="line-height:25px"> updateAllCheckState();<br style="line-height:25px"> }<br style="line-height:25px"> });<br style="line-height:25px"><br style="line-height:25px"> }<br style="line-height:25px"><br style="line-height:25px"> /*<br style="line-height:25px"> *AgendaItem?mAgendarcolor???display??drawable<br style="line-height:25px"> */<br style="line-height:25px"> privateInteger[]mAgendaColorDrawable={<br style="line-height:25px"> R.drawable.listlayoutsample2xml_agenda_color01,<br style="line-height:25px"> R.drawable.listlayoutsample2xml_agenda_color02,<br style="line-height:25px"> R.drawable.listlayoutsample2xml_agenda_color03,<br style="line-height:25px"> R.drawable.listlayoutsample2xml_agenda_color04,<br style="line-height:25px"> R.drawable.listlayoutsample2xml_agenda_color05,<br style="line-height:25px"> R.drawable.listlayoutsample2xml_agenda_color06};<br style="line-height:25px"><br style="line-height:25px"> /*<br style="line-height:25px"> *AgendaItem?mAgendatabicon???display??drawable<br style="line-height:25px"> */<br style="line-height:25px"> privateInteger[]mAgendaTagDrawable={<br style="line-height:25px"> -1,-1,R.drawable.listlayoutsample2xml_icon_facebook};<br style="line-height:25px"><br style="line-height:25px"> /*<br style="line-height:25px"> *?????AgendaItem???????data<br style="line-height:25px"> */<br style="line-height:25px"> /*<br style="line-height:25px"> *AgendaItem?mAgendarcolor????data<br style="line-height:25px"> */<br style="line-height:25px"> privateint[]mAgendaColor=<br style="line-height:25px"> {<br style="line-height:25px"> AGENDA_CYAN,<br style="line-height:25px"> AGENDA_BLUE,<br style="line-height:25px"> AGENDA_GREEN,<br style="line-height:25px"> AGENDA_PURPLE,<br style="line-height:25px"> AGENDA_YELLOW,<br style="line-height:25px"> AGENDA_COBALT<br style="line-height:25px"> };<br style="line-height:25px"><br style="line-height:25px"> /*<br style="line-height:25px"> *AgendaItem?mAgendatabicon????data<br style="line-height:25px"> */<br style="line-height:25px"> privateint[]mAgendaTagIcon=<br style="line-height:25px"> {<br style="line-height:25px"> AGENDA_TAG_ICON_NONE,<br style="line-height:25px"> AGENDA_TAG_ICON_NONE,<br style="line-height:25px"> AGENDA_TAG_ICON_NONE,<br style="line-height:25px"> AGENDA_TAG_ICON_NONE,<br style="line-height:25px"> AGENDA_TAG_ICON_NONE,<br style="line-height:25px"> AGENDA_TAG_ICON_FACEBOOK<br style="line-height:25px"> };<br style="line-height:25px"><br style="line-height:25px"> /*<br style="line-height:25px"> *AgendaItem?mAgenda????data<br style="line-height:25px"> */<br style="line-height:25px"> privateString[]mAgenda=<br style="line-height:25px"> {<br style="line-height:25px"> "Personal",<br style="line-height:25px"> "Work",<br style="line-height:25px"> "UXConcil",<br style="line-height:25px"> "Holiday",<br style="line-height:25px"> "Event",<br style="line-height:25px"> "Facebook"<br style="line-height:25px"> };<br style="line-height:25px"><br style="line-height:25px"> /*<br style="line-height:25px"> *AgendaItem?mTag????data<br style="line-height:25px"> */<br style="line-height:25px"> privateString[]mTag=<br style="line-height:25px"> {<br style="line-height:25px"> "",<br style="line-height:25px"> "Google",<br style="line-height:25px"> "Google",<br style="line-height:25px"> "",<br style="line-height:25px"> "Google",<br style="line-height:25px"> "Facebook"<br style="line-height:25px"> };<br style="line-height:25px"><br style="line-height:25px"> /*<br style="line-height:25px"> *ListView?????Adapter.ArrayAdapter???????.<br style="line-height:25px"> *AgendaItemtype?data??ArrayList????.<br style="line-height:25px"> */<br style="line-height:25px"> privateclassAgendaAdapterextendsArrayAdapter<AgendaItem>{<br style="line-height:25px"><br style="line-height:25px"> privateArrayList<AgendaItem>items;<br style="line-height:25px"><br style="line-height:25px"> publicAgendaAdapter(Contextcontext,inttextViewResourceId,ArrayList<AgendaItem>items){<br style="line-height:25px"> super(context,textViewResourceId,items);<br style="line-height:25px"> this.items=items;<br style="line-height:25px"> }<br style="line-height:25px"> @Override<br style="line-height:25px"> publicViewgetView(intposition,ViewconvertView,ViewGroupparent){<br style="line-height:25px"> Viewv=convertView;<br style="line-height:25px"> if(v==null){<br style="line-height:25px"> LayoutInflatervi=(LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);<br style="line-height:25px"> v=vi.inflate(R.layout.listlayoutsample2xml_row,null);<br style="line-height:25px"> }<br style="line-height:25px"> AgendaItemti=items.get(position);<br style="line-height:25px"> if(ti!=null){<br style="line-height:25px"> /*<br style="line-height:25px"> *List?item????????View?data?????.<br style="line-height:25px"> *AgendaItemclass?gettermethod?????data???????.<br style="line-height:25px"> */<br style="line-height:25px"> ImageViewivAgendaColor=(ImageView)v.findViewById(R.id.icon1);<br style="line-height:25px"> ImageViewivAgendaTag=(ImageView)v.findViewById(R.id.icon2);<br style="line-height:25px"> TextViewtvAgendaText=(TextView)v.findViewById(R.id.text1);<br style="line-height:25px"> TextViewtvTag=(TextView)v.findViewById(R.id.text2);<br style="line-height:25px"> finalCheckBoxcheck=(CheckBox)v.findViewById(R.id.checkbox1);<br style="line-height:25px"><br style="line-height:25px"> //AgendaColor<br style="line-height:25px"> if(ivAgendaColor!=null){<br style="line-height:25px"> intagendaIconType;<br style="line-height:25px"><br style="line-height:25px"> //getAgendaColorType?AgendaColorType?get??<br style="line-height:25px"> //??????drawable?imageViewBackgroundResource????.<br style="line-height:25px"> intcolortype=ti.getAgendaColorType();<br style="line-height:25px"> agendaIconType=getAgendaIconType(colortype);<br style="line-height:25px"> //ivAgendaColor.setImageResource(mAgendaColorDrawable[agendaIconType]);<br style="line-height:25px"> ivAgendaColor.setBackgroundResource(mAgendaColorDrawable[agendaIconType]);<br style="line-height:25px"> }<br style="line-height:25px"><br style="line-height:25px"> //AgendaIcon<br style="line-height:25px"> if(ivAgendaTag!=null){<br style="line-height:25px"> //getAgendaTagIconTyp?AgendaTagIconType?get??<br style="line-height:25px"> //??????drawable?imageViewResource????.<br style="line-height:25px"> inticontype=ti.getAgendaTagIconType();<br style="line-height:25px"> intvisibility=getAgendaTagVisibility(icontype);<br style="line-height:25px"> ivAgendaTag.setVisibility(visibility);<br style="line-height:25px"><br style="line-height:25px"> Log.i(TAG,"getView::icontypeis"+icontype);<br style="line-height:25px"> if(icontype!=-1&&mAgendaTagDrawable[icontype-AGENDA_TAG_ICON_NONE]!=-1)<br style="line-height:25px"> ivAgendaTag.setImageResource(mAgendaTagDrawable[icontype-AGENDA_TAG_ICON_NONE]);<br style="line-height:25px"> }<br style="line-height:25px"><br style="line-height:25px"> //AgendaText<br style="line-height:25px"> if(tvAgendaText!=null){<br style="line-height:25px"> tvAgendaText.setText(ti.getAgendaText());<br style="line-height:25px"> }<br style="line-height:25px"><br style="line-height:25px"> //AgendaTag<br style="line-height:25px"> if(tvTag!=null){<br style="line-height:25px"> //AgendaTagText?null??????TextView?display??????<br style="line-height:25px"> //Visibility?GONE??????.<br style="line-height:25px"> //INVISIBLE????GONE????TabText?????AgendaText?CenterAlign???????.<br style="line-height:25px"> Stringtagstring=ti.getAgendaTag();<br style="line-height:25px"> if(tagstring.length()==0)<br style="line-height:25px"> {<br style="line-height:25px"> Log.i("TouchWiz3List2","getView::item("+position+")'sTagTextlengthis0");<br style="line-height:25px"> tvTag.setVisibility(View.GONE);<br style="line-height:25px"> }<br style="line-height:25px"> else{<br style="line-height:25px"> tvTag.setText(ti.getAgendaTag());<br style="line-height:25px"> //[09.10.23]converView???????????setting?reset??????.<br style="line-height:25px"> tvTag.setVisibility(View.VISIBLE);<br style="line-height:25px"> }<br style="line-height:25px"> }<br style="line-height:25px"> if(check!=null){<br style="line-height:25px"> finalintmyPosition=position;<br style="line-height:25px"> check.setOnClickListener(newOnClickListener(){<br style="line-height:25px"><br style="line-height:25px"> publicvoidonClick(Viewv){<br style="line-height:25px"><br style="line-height:25px"> //???onBtnCheckChanged()???????????????<br style="line-height:25px"> //???????????????,onBtnCheckChanged()?<br style="line-height:25px"> //post??.<br style="line-height:25px"> //[E]Toavoidsceenflicker,postonBtnCheckChanged()insteadofdirectcalling.<br style="line-height:25px"><br style="line-height:25px"> check.post(newRunnable(){<br style="line-height:25px"> publicvoidrun(){<br style="line-height:25px"> booleanfchecked=check.isChecked();<br style="line-height:25px"> onBtnCheckChanged(myPosition,fchecked);<br style="line-height:25px"> }<br style="line-height:25px"> });<br style="line-height:25px"><br style="line-height:25px"> }<br style="line-height:25px"> });<br style="line-height:25px"> }<br style="line-height:25px"><br style="line-height:25px"> }<br style="line-height:25px"> returnv;<br style="line-height:25px"> }<br style="line-height:25px"> }<br style="line-height:25px"><br style="line-height:25px"> privatevoidonBtnCheckChanged(intposition,booleancheck){<br style="line-height:25px"> Log.d(TAG,"onBtnCheckChanged("+position+","+check+")");<br style="line-height:25px"><br style="line-height:25px"> //ListView.setItemChecked()???headerView??????????????.<br style="line-height:25px"> mList.setItemChecked(position+mList.getHeaderViewsCount(),check);<br style="line-height:25px"><br style="line-height:25px"> updateAllCheckState();<br style="line-height:25px"> }<br style="line-height:25px"><br style="line-height:25px"> privatevoidupdateAllCheckState(){<br style="line-height:25px"> Log.d("updateAllCheckState","called");<br style="line-height:25px"><br style="line-height:25px"> booleaneveryBodyIsOn=true;<br style="line-height:25px"><br style="line-height:25px"> //dataCount????????+?????<br style="line-height:25px"> intdataCount=mList.getCount();<br style="line-height:25px"><br style="line-height:25px"> for(inti=mList.getHeaderViewsCount();i<dataCount&&everyBodyIsOn;++i){<br style="line-height:25px"> //ListView.isItemChecked()???headerView??????????????.<br style="line-height:25px"> booleanchecked=mList.isItemChecked(i);<br style="line-height:25px"> Log.d("updateAllCheckState","checked["+i+"]:"+checked);<br style="line-height:25px"> if(!checked){<br style="line-height:25px"> everyBodyIsOn=false;<br style="line-height:25px"> }<br style="line-height:25px"> }<br style="line-height:25px"><br style="line-height:25px"> mHeaderAllCheckBox.setChecked(everyBodyIsOn);<br style="line-height:25px"> }<br style="line-height:25px"><br style="line-height:25px"><br style="line-height:25px"> /**<br style="line-height:25px"> *@paramagendacolor<br style="line-height:25px"> *@returnagendacolor?????drawable?type<br style="line-height:25px"> */<br style="line-height:25px"> publicintgetAgendaIconType(intagendacolor){<br style="line-height:25px"> inttype=-1;<br style="line-height:25px"> switch(agendacolor)<br style="line-height:25px"> {<br style="line-height:25px"> caseAGENDA_CYAN:<br style="line-height:25px"> type=0;<br style="line-height:25px"> break;<br style="line-height:25px"> caseAGENDA_BLUE:<br style="line-height:25px"> type=1;<br style="line-height:25px"> break;<br style="line-height:25px"> caseAGENDA_GREEN:<br style="line-height:25px"> type=2;<br style="line-height:25px"> break;<br style="line-height:25px"> caseAGENDA_PURPLE:<br style="line-height:25px"> type=3;<br style="line-height:25px"> break;<br style="line-height:25px"> caseAGENDA_YELLOW:<br style="line-height:25px"> type=4;<br style="line-height:25px"> break;<br style="line-height:25px"> caseAGENDA_COBALT:<br style="line-height:25px"> type=5;<br style="line-height:25px"> break;<br style="line-height:25px"> caseAGENDA_NONE:<br style="line-height:25px"> default:<br style="line-height:25px"> type=-1;<br style="line-height:25px"> break;<br style="line-height:25px"> }<br style="line-height:25px"> returntype;<br style="line-height:25px"> }<br style="line-height:25px"><br style="line-height:25px"> //[09.10.23]newlyadded!tosetstatusofallitems.<br style="line-height:25px"> publicvoidsetAllItemChecked(booleanbCheckStatus){<br style="line-height:25px"> intdataCount=mList.getCount();<br style="line-height:25px"> for(inti=0;i<dataCount;++i){<br style="line-height:25px"> //ListView.setItemChecked()???????ListView??????<br style="line-height:25px"> //requestLayout()???????????itemrow????<br style="line-height:25px"> //getView()?????????.<br style="line-height:25px"> mList.setItemChecked(i,bCheckStatus);<br style="line-height:25px"> }<br style="line-height:25px"> }<br style="line-height:25px"><br style="line-height:25px"> publicintgetAgendaTagVisibility(intagendaicontype)<br style="line-height:25px"> {<br style="line-height:25px"> intvisibility=View.VISIBLE;<br style="line-height:25px"><br style="line-height:25px"> switch(agendaicontype)<br style="line-height:25px"> {<br style="line-height:25px"> caseAGENDA_TAG_ICON_FACEBOOK:<br style="line-height:25px"> visibility=View.VISIBLE;<br style="line-height:25px"> break;<br style="line-height:25px"> caseAGENDA_TAG_ICON_GOOGLE:<br style="line-height:25px"> visibility=View.INVISIBLE;<br style="line-height:25px"> break;<br style="line-height:25px"> caseAGENDA_TAG_ICON_NONE:<br style="line-height:25px"> default:<br style="line-height:25px"> visibility=View.GONE;<br style="line-height:25px"> break;<br style="line-height:25px"> }<br style="line-height:25px"><br style="line-height:25px"> returnvisibility;<br style="line-height:25px"> }<br style="line-height:25px"><br style="line-height:25px"><span style="color:#808080; line-height:25px">/**<br style="line-height:25px"> *@authorcooldawn.kim<br style="line-height:25px"> *<br style="line-height:25px"> *AgendaItem<br style="line-height:25px"> */</span><br style="line-height:25px"><span style="color:#3366ff; line-height:25px"></span><span style="color:#993300; line-height:25px">class</span><span style="color:#3366ff; line-height:25px"></span><span style="color:#ff6600; line-height:25px">AgendaItem</span><span style="color:#3366ff; line-height:25px">{<br style="line-height:25px"> privateintmAgendarcolor;<br style="line-height:25px"> privateintmAgendatabicon;<br style="line-height:25px"> privateStringmAgenda;<br style="line-height:25px"> privateStringmTag;<br style="line-height:25px"><br style="line-height:25px"> publicAgendaItem(intcolor,inttagicon,Stringagenda,Stringtag)<br style="line-height:25px"> {<br style="line-height:25px"> this.mAgendarcolor=color;<br style="line-height:25px"> this.mAgendatabicon=tagicon;<br style="line-height:25px"> this.mAgenda=agenda;<br style="line-height:25px"> this.mTag=tag;<br style="line-height:25px"> }<br style="line-height:25px"><br style="line-height:25px"> publicintgetAgendaColorType(){<br style="line-height:25px"> returnmAgendarcolor;<br style="line-height:25px"> }<br style="line-height:25px"><br style="line-height:25px"> publicintgetAgendaTagIconType(){<br style="line-height:25px"> returnmAgendatabicon;<br style="line-height:25px"> }<br style="line-height:25px"><br style="line-height:25px"> publicStringgetAgendaText(){<br style="line-height:25px"> returnmAgenda;<br style="line-height:25px"> }<br style="line-height:25px"><br style="line-height:25px"> publicStringgetAgendaTag(){<br style="line-height:25px"> returnmTag;<br style="line-height:25px"> }<br style="line-height:25px"><br style="line-height:25px"> }//classAgendaItem</span><br style="line-height:25px"><br style="line-height:25px"><span style="color:#808080; line-height:25px">/**<br style="line-height:25px"> *[09.10.23]<br style="line-height:25px"> *@authorrhoon<br style="line-height:25px"> *<br style="line-height:25px"> *publicclass<br style="line-height:25px"> *Checkablelinearlayout.??Checkable?????????????<br style="line-height:25px"> *?????forwarding????????.<br style="line-height:25px"> */</span><br style="line-height:25px"><span style="color:#3366ff; line-height:25px"></span><span style="color:#993300; line-height:25px">publicstaticclass</span><span style="color:#3366ff; line-height:25px"></span><span style="color:#ff6600; line-height:25px">ItemView</span><span style="color:#3366ff; line-height:25px">extendsLinearLayoutimplementsCheckable{</span><br style="line-height:25px"><br style="line-height:25px"><span style="color:#3366ff; line-height:25px">publicItemView(Contextcontext,AttributeSetattrs){</span><br style="line-height:25px"><span style="color:#3366ff; line-height:25px">super(context,attrs);</span><br style="line-height:25px"><span style="color:#3366ff; line-height:25px">}</span><br style="line-height:25px"><br style="line-height:25px"><span style="color:#3366ff; line-height:25px">publicbooleanisChecked(){</span><br style="line-height:25px"><span style="color:#3366ff; line-height:25px">CheckBoxcheck=findCheckBox();</span><br style="line-height:25px"><span style="color:#3366ff; line-height:25px">if(check!=null){</span><br style="line-height:25px"><span style="color:#3366ff; line-height:25px">returncheck.isChecked();</span><br style="line-height:25px"><span style="color:#3366ff; line-height:25px">}</span><br style="line-height:25px"><span style="color:#3366ff; line-height:25px">returnfalse;</span><br style="line-height:25px"><span style="color:#3366ff; line-height:25px">}</span><br style="line-height:25px"><br style="line-height:25px"><span style="color:#3366ff; line-height:25px">publicvoidsetChecked(booleanchecked){</span><br style="line-height:25px"><span style="color:#3366ff; line-height:25px">Log.d("ItemView","setChecked("+checked+")");</span><br style="line-height:25px"><span style="color:#3366ff; line-height:25px">CheckBoxcheck=findCheckBox();</span><br style="line-height:25px"><span style="color:#3366ff; line-height:25px">if(check!=null){</span><br style="line-height:25px"><span style="color:#3366ff; line-height:25px">check.setChecked(checked);</span><br style="line-height:25px"><span style="color:#3366ff; line-height:25px">}</span><br style="line-height:25px"><span style="color:#3366ff; line-height:25px">}</span><br style="line-height:25px"><br style="line-height:25px"><span style="color:#3366ff; line-height:25px">publicvoidtoggle(){</span><br style="line-height:25px"><span style="color:#3366ff; line-height:25px">CheckBoxcheck=findCheckBox();</span><br style="line-height:25px"><span style="color:#3366ff; line-height:25px">if(check!=null){</span><br style="line-height:25px"><span style="color:#3366ff; line-height:25px">check.toggle();</span><br style="line-height:25px"><span style="color:#3366ff; line-height:25px">}</span><br style="line-height:25px"><span style="color:#3366ff; line-height:25px"></span><br style="line-height:25px"><span style="color:#3366ff; line-height:25px">}</span><br style="line-height:25px"><span style="color:#3366ff; line-height:25px"></span><br style="line-height:25px"><span style="color:#3366ff; line-height:25px">privateCheckBoxfindCheckBox(){</span><br style="line-height:25px"><span style="color:#3366ff; line-height:25px">Viewcheck=findViewById(R.id.checkbox1);</span><br style="line-height:25px"><span style="color:#3366ff; line-height:25px">if(check!=null&&checkinstanceofCheckBox){</span><br style="line-height:25px"><span style="color:#3366ff; line-height:25px">return(CheckBox)check;</span><br style="line-height:25px"><span style="color:#3366ff; line-height:25px">}</span><br style="line-height:25px"><span style="color:#3366ff; line-height:25px">returnnull;</span><br style="line-height:25px"><span style="color:#3366ff; line-height:25px">}</span><br style="line-height:25px"><span style="color:#3366ff; line-height:25px"></span><br style="line-height:25px"><span style="color:#3366ff; line-height:25px">}</span><br style="line-height:25px"> }</wbr></wbr></wbr></wbr>
importandroid.app.Activity;
importandroid.content.Context;
importandroid.os.Bundle;
importandroid.util.AttributeSet;
importandroid.util.Log;
importandroid.view.LayoutInflater;
importandroid.view.View;
importandroid.view.ViewGroup;
importandroid.view.View.OnClickListener;
importandroid.widget.AdapterView;
importandroid.widget.ArrayAdapter;
importandroid.widget.CheckBox;
importandroid.widget.Checkable;
importandroid.widget.ImageView;
importandroid.widget.LinearLayout;
importandroid.widget.ListView;
importandroid.widget.TextView;
importandroid.widget.AdapterView.OnItemClickListener;
importcom.sec.android.touchwiz.samples.R;
publicclassListLayoutSample2XmlextendsActivity{
privatestaticfinalStringTAG="ListLayoutSample2Xml";
privateListViewmList;
privateCheckBoxmHeaderAllCheckBox;
privatefinalintAGENDA_NONE=0;
privatefinalintAGENDA_CYAN=1;
privatefinalintAGENDA_BLUE=2;
privatefinalintAGENDA_GREEN=3;
privatefinalintAGENDA_PURPLE=4;
privatefinalintAGENDA_YELLOW=5;
privatefinalintAGENDA_COBALT=6;
privatefinalintAGENDA_TAG_ICON_NONE=100;
privatefinalintAGENDA_TAG_ICON_GOOGLE=101;
privatefinalintAGENDA_TAG_ICON_FACEBOOK=102;
/**Calledwhentheactivityisfirstcreated.*/
@Override
publicvoidonCreate(BundlesavedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.listlayoutsample2xml_main);
mList=(ListView)findViewById(R.id.agendaAllList);
mList.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
Viewallitem=getLayoutInflater().inflate(R.layout.listlayoutsample2xml_allitem,null);
mHeaderAllCheckBox=(CheckBox)allitem.findViewById(R.id.allitemcheck);
//[09.10.23]newlyadded!!!allitemclickListenertosetcheckstatusofallitems.
allitem.setOnClickListener(newOnClickListener(){
publicvoidonClick(Viewview){
Log.d("allitemheader","onClick()");
mHeaderAllCheckBox.performClick();
}
});
mHeaderAllCheckBox.setOnClickListener(newOnClickListener(){
publicvoidonClick(Viewview){
Log.d("allitemheadercheckbox","onClick()");
CheckBoxcheckBox=(CheckBox)view;
booleanchecked=checkBox.isChecked();
setAllItemChecked(checked);
}
});
mList.addHeaderView(allitem);
mList.post(newRunnable(){
publicvoidrun(){
updateAllCheckState();
}
});
LayoutInflaterli=(LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
Viewallitem=li.inflate(R.layout.touchwiz3list2_allitem,null);
LinearLayoutallitem=(LinearLayout)findViewById(R.id.allitem);
allitem=newLinearLayout(this);
if(allitem==null)
Log.i("TouchWiz3List2","allitemviewisnull");
else
{
TextViewallitemtext=(TextView)findViewById(R.id.allitemtext);
allitemtext=newTextView(this);
CheckBoxallitemcheck=(CheckBox)findViewById(R.id.allitemcheck);
allitemcheck=newCheckBox(this);
allitemtext.setText("Allcalendar");
allitemtext.setTextSize(36);
allitemtext.setTextColor(Color.WHITE);
allitemtext.setPadding(20,allitemtext.getPaddingTop(),allitemtext.getPaddingRight(),allitemtext.getPaddingBottom());
allitem.setMinimumHeight(90);
allitem.setGravity(Gravity.CENTER_VERTICAL);
allitem.setBackgroundDrawable(getResources().getDrawable(R.drawable.winset_selectall_bg));
allitem.addView(allitemtext);
allitem.addView(allitemcheck);
agendaList.addHeaderView(allitem);
}
*/
//AgendaItemtype?item???ArrayList???
ArrayList<AgendaItem>list=newArrayList<AgendaItem>();
//mAgenda????for????ArrayList?itemadd
for(inti=0;i<mAgenda.length;i++){
AgendaItemcontact=newAgendaItem(mAgendaColor<wbr style="line-height:25px">,mAgendaTagIcon<wbr style="line-height:25px">,mAgenda<wbr style="line-height:25px">,mTag<wbr style="line-height:25px">);<br style="line-height:25px"> list.add(contact);<br style="line-height:25px"> }<br style="line-height:25px"><br style="line-height:25px"> //AgendaAdapter??<br style="line-height:25px"> AgendaAdapteragendaAdapter=newAgendaAdapter(this,R.layout.listlayoutsample2xml_row,list);<br style="line-height:25px"> //ListView?AgendaAdapter??<br style="line-height:25px"> mList.setAdapter(agendaAdapter);<br style="line-height:25px"><br style="line-height:25px"> mList.setOnItemClickListener(newOnItemClickListener(){<br style="line-height:25px"> publicvoidonItemClick(AdapterView<?>parent,Viewview,<br style="line-height:25px"> intposition,longid){<br style="line-height:25px"> Log.d(TAG,"onItemClick("+position+")");<br style="line-height:25px"><br style="line-height:25px"> updateAllCheckState();<br style="line-height:25px"> }<br style="line-height:25px"> });<br style="line-height:25px"><br style="line-height:25px"> }<br style="line-height:25px"><br style="line-height:25px"> /*<br style="line-height:25px"> *AgendaItem?mAgendarcolor???display??drawable<br style="line-height:25px"> */<br style="line-height:25px"> privateInteger[]mAgendaColorDrawable={<br style="line-height:25px"> R.drawable.listlayoutsample2xml_agenda_color01,<br style="line-height:25px"> R.drawable.listlayoutsample2xml_agenda_color02,<br style="line-height:25px"> R.drawable.listlayoutsample2xml_agenda_color03,<br style="line-height:25px"> R.drawable.listlayoutsample2xml_agenda_color04,<br style="line-height:25px"> R.drawable.listlayoutsample2xml_agenda_color05,<br style="line-height:25px"> R.drawable.listlayoutsample2xml_agenda_color06};<br style="line-height:25px"><br style="line-height:25px"> /*<br style="line-height:25px"> *AgendaItem?mAgendatabicon???display??drawable<br style="line-height:25px"> */<br style="line-height:25px"> privateInteger[]mAgendaTagDrawable={<br style="line-height:25px"> -1,-1,R.drawable.listlayoutsample2xml_icon_facebook};<br style="line-height:25px"><br style="line-height:25px"> /*<br style="line-height:25px"> *?????AgendaItem???????data<br style="line-height:25px"> */<br style="line-height:25px"> /*<br style="line-height:25px"> *AgendaItem?mAgendarcolor????data<br style="line-height:25px"> */<br style="line-height:25px"> privateint[]mAgendaColor=<br style="line-height:25px"> {<br style="line-height:25px"> AGENDA_CYAN,<br style="line-height:25px"> AGENDA_BLUE,<br style="line-height:25px"> AGENDA_GREEN,<br style="line-height:25px"> AGENDA_PURPLE,<br style="line-height:25px"> AGENDA_YELLOW,<br style="line-height:25px"> AGENDA_COBALT<br style="line-height:25px"> };<br style="line-height:25px"><br style="line-height:25px"> /*<br style="line-height:25px"> *AgendaItem?mAgendatabicon????data<br style="line-height:25px"> */<br style="line-height:25px"> privateint[]mAgendaTagIcon=<br style="line-height:25px"> {<br style="line-height:25px"> AGENDA_TAG_ICON_NONE,<br style="line-height:25px"> AGENDA_TAG_ICON_NONE,<br style="line-height:25px"> AGENDA_TAG_ICON_NONE,<br style="line-height:25px"> AGENDA_TAG_ICON_NONE,<br style="line-height:25px"> AGENDA_TAG_ICON_NONE,<br style="line-height:25px"> AGENDA_TAG_ICON_FACEBOOK<br style="line-height:25px"> };<br style="line-height:25px"><br style="line-height:25px"> /*<br style="line-height:25px"> *AgendaItem?mAgenda????data<br style="line-height:25px"> */<br style="line-height:25px"> privateString[]mAgenda=<br style="line-height:25px"> {<br style="line-height:25px"> "Personal",<br style="line-height:25px"> "Work",<br style="line-height:25px"> "UXConcil",<br style="line-height:25px"> "Holiday",<br style="line-height:25px"> "Event",<br style="line-height:25px"> "Facebook"<br style="line-height:25px"> };<br style="line-height:25px"><br style="line-height:25px"> /*<br style="line-height:25px"> *AgendaItem?mTag????data<br style="line-height:25px"> */<br style="line-height:25px"> privateString[]mTag=<br style="line-height:25px"> {<br style="line-height:25px"> "",<br style="line-height:25px"> "Google",<br style="line-height:25px"> "Google",<br style="line-height:25px"> "",<br style="line-height:25px"> "Google",<br style="line-height:25px"> "Facebook"<br style="line-height:25px"> };<br style="line-height:25px"><br style="line-height:25px"> /*<br style="line-height:25px"> *ListView?????Adapter.ArrayAdapter???????.<br style="line-height:25px"> *AgendaItemtype?data??ArrayList????.<br style="line-height:25px"> */<br style="line-height:25px"> privateclassAgendaAdapterextendsArrayAdapter<AgendaItem>{<br style="line-height:25px"><br style="line-height:25px"> privateArrayList<AgendaItem>items;<br style="line-height:25px"><br style="line-height:25px"> publicAgendaAdapter(Contextcontext,inttextViewResourceId,ArrayList<AgendaItem>items){<br style="line-height:25px"> super(context,textViewResourceId,items);<br style="line-height:25px"> this.items=items;<br style="line-height:25px"> }<br style="line-height:25px"> @Override<br style="line-height:25px"> publicViewgetView(intposition,ViewconvertView,ViewGroupparent){<br style="line-height:25px"> Viewv=convertView;<br style="line-height:25px"> if(v==null){<br style="line-height:25px"> LayoutInflatervi=(LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);<br style="line-height:25px"> v=vi.inflate(R.layout.listlayoutsample2xml_row,null);<br style="line-height:25px"> }<br style="line-height:25px"> AgendaItemti=items.get(position);<br style="line-height:25px"> if(ti!=null){<br style="line-height:25px"> /*<br style="line-height:25px"> *List?item????????View?data?????.<br style="line-height:25px"> *AgendaItemclass?gettermethod?????data???????.<br style="line-height:25px"> */<br style="line-height:25px"> ImageViewivAgendaColor=(ImageView)v.findViewById(R.id.icon1);<br style="line-height:25px"> ImageViewivAgendaTag=(ImageView)v.findViewById(R.id.icon2);<br style="line-height:25px"> TextViewtvAgendaText=(TextView)v.findViewById(R.id.text1);<br style="line-height:25px"> TextViewtvTag=(TextView)v.findViewById(R.id.text2);<br style="line-height:25px"> finalCheckBoxcheck=(CheckBox)v.findViewById(R.id.checkbox1);<br style="line-height:25px"><br style="line-height:25px"> //AgendaColor<br style="line-height:25px"> if(ivAgendaColor!=null){<br style="line-height:25px"> intagendaIconType;<br style="line-height:25px"><br style="line-height:25px"> //getAgendaColorType?AgendaColorType?get??<br style="line-height:25px"> //??????drawable?imageViewBackgroundResource????.<br style="line-height:25px"> intcolortype=ti.getAgendaColorType();<br style="line-height:25px"> agendaIconType=getAgendaIconType(colortype);<br style="line-height:25px"> //ivAgendaColor.setImageResource(mAgendaColorDrawable[agendaIconType]);<br style="line-height:25px"> ivAgendaColor.setBackgroundResource(mAgendaColorDrawable[agendaIconType]);<br style="line-height:25px"> }<br style="line-height:25px"><br style="line-height:25px"> //AgendaIcon<br style="line-height:25px"> if(ivAgendaTag!=null){<br style="line-height:25px"> //getAgendaTagIconTyp?AgendaTagIconType?get??<br style="line-height:25px"> //??????drawable?imageViewResource????.<br style="line-height:25px"> inticontype=ti.getAgendaTagIconType();<br style="line-height:25px"> intvisibility=getAgendaTagVisibility(icontype);<br style="line-height:25px"> ivAgendaTag.setVisibility(visibility);<br style="line-height:25px"><br style="line-height:25px"> Log.i(TAG,"getView::icontypeis"+icontype);<br style="line-height:25px"> if(icontype!=-1&&mAgendaTagDrawable[icontype-AGENDA_TAG_ICON_NONE]!=-1)<br style="line-height:25px"> ivAgendaTag.setImageResource(mAgendaTagDrawable[icontype-AGENDA_TAG_ICON_NONE]);<br style="line-height:25px"> }<br style="line-height:25px"><br style="line-height:25px"> //AgendaText<br style="line-height:25px"> if(tvAgendaText!=null){<br style="line-height:25px"> tvAgendaText.setText(ti.getAgendaText());<br style="line-height:25px"> }<br style="line-height:25px"><br style="line-height:25px"> //AgendaTag<br style="line-height:25px"> if(tvTag!=null){<br style="line-height:25px"> //AgendaTagText?null??????TextView?display??????<br style="line-height:25px"> //Visibility?GONE??????.<br style="line-height:25px"> //INVISIBLE????GONE????TabText?????AgendaText?CenterAlign???????.<br style="line-height:25px"> Stringtagstring=ti.getAgendaTag();<br style="line-height:25px"> if(tagstring.length()==0)<br style="line-height:25px"> {<br style="line-height:25px"> Log.i("TouchWiz3List2","getView::item("+position+")'sTagTextlengthis0");<br style="line-height:25px"> tvTag.setVisibility(View.GONE);<br style="line-height:25px"> }<br style="line-height:25px"> else{<br style="line-height:25px"> tvTag.setText(ti.getAgendaTag());<br style="line-height:25px"> //[09.10.23]converView???????????setting?reset??????.<br style="line-height:25px"> tvTag.setVisibility(View.VISIBLE);<br style="line-height:25px"> }<br style="line-height:25px"> }<br style="line-height:25px"> if(check!=null){<br style="line-height:25px"> finalintmyPosition=position;<br style="line-height:25px"> check.setOnClickListener(newOnClickListener(){<br style="line-height:25px"><br style="line-height:25px"> publicvoidonClick(Viewv){<br style="line-height:25px"><br style="line-height:25px"> //???onBtnCheckChanged()???????????????<br style="line-height:25px"> //???????????????,onBtnCheckChanged()?<br style="line-height:25px"> //post??.<br style="line-height:25px"> //[E]Toavoidsceenflicker,postonBtnCheckChanged()insteadofdirectcalling.<br style="line-height:25px"><br style="line-height:25px"> check.post(newRunnable(){<br style="line-height:25px"> publicvoidrun(){<br style="line-height:25px"> booleanfchecked=check.isChecked();<br style="line-height:25px"> onBtnCheckChanged(myPosition,fchecked);<br style="line-height:25px"> }<br style="line-height:25px"> });<br style="line-height:25px"><br style="line-height:25px"> }<br style="line-height:25px"> });<br style="line-height:25px"> }<br style="line-height:25px"><br style="line-height:25px"> }<br style="line-height:25px"> returnv;<br style="line-height:25px"> }<br style="line-height:25px"> }<br style="line-height:25px"><br style="line-height:25px"> privatevoidonBtnCheckChanged(intposition,booleancheck){<br style="line-height:25px"> Log.d(TAG,"onBtnCheckChanged("+position+","+check+")");<br style="line-height:25px"><br style="line-height:25px"> //ListView.setItemChecked()???headerView??????????????.<br style="line-height:25px"> mList.setItemChecked(position+mList.getHeaderViewsCount(),check);<br style="line-height:25px"><br style="line-height:25px"> updateAllCheckState();<br style="line-height:25px"> }<br style="line-height:25px"><br style="line-height:25px"> privatevoidupdateAllCheckState(){<br style="line-height:25px"> Log.d("updateAllCheckState","called");<br style="line-height:25px"><br style="line-height:25px"> booleaneveryBodyIsOn=true;<br style="line-height:25px"><br style="line-height:25px"> //dataCount????????+?????<br style="line-height:25px"> intdataCount=mList.getCount();<br style="line-height:25px"><br style="line-height:25px"> for(inti=mList.getHeaderViewsCount();i<dataCount&&everyBodyIsOn;++i){<br style="line-height:25px"> //ListView.isItemChecked()???headerView??????????????.<br style="line-height:25px"> booleanchecked=mList.isItemChecked(i);<br style="line-height:25px"> Log.d("updateAllCheckState","checked["+i+"]:"+checked);<br style="line-height:25px"> if(!checked){<br style="line-height:25px"> everyBodyIsOn=false;<br style="line-height:25px"> }<br style="line-height:25px"> }<br style="line-height:25px"><br style="line-height:25px"> mHeaderAllCheckBox.setChecked(everyBodyIsOn);<br style="line-height:25px"> }<br style="line-height:25px"><br style="line-height:25px"><br style="line-height:25px"> /**<br style="line-height:25px"> *@paramagendacolor<br style="line-height:25px"> *@returnagendacolor?????drawable?type<br style="line-height:25px"> */<br style="line-height:25px"> publicintgetAgendaIconType(intagendacolor){<br style="line-height:25px"> inttype=-1;<br style="line-height:25px"> switch(agendacolor)<br style="line-height:25px"> {<br style="line-height:25px"> caseAGENDA_CYAN:<br style="line-height:25px"> type=0;<br style="line-height:25px"> break;<br style="line-height:25px"> caseAGENDA_BLUE:<br style="line-height:25px"> type=1;<br style="line-height:25px"> break;<br style="line-height:25px"> caseAGENDA_GREEN:<br style="line-height:25px"> type=2;<br style="line-height:25px"> break;<br style="line-height:25px"> caseAGENDA_PURPLE:<br style="line-height:25px"> type=3;<br style="line-height:25px"> break;<br style="line-height:25px"> caseAGENDA_YELLOW:<br style="line-height:25px"> type=4;<br style="line-height:25px"> break;<br style="line-height:25px"> caseAGENDA_COBALT:<br style="line-height:25px"> type=5;<br style="line-height:25px"> break;<br style="line-height:25px"> caseAGENDA_NONE:<br style="line-height:25px"> default:<br style="line-height:25px"> type=-1;<br style="line-height:25px"> break;<br style="line-height:25px"> }<br style="line-height:25px"> returntype;<br style="line-height:25px"> }<br style="line-height:25px"><br style="line-height:25px"> //[09.10.23]newlyadded!tosetstatusofallitems.<br style="line-height:25px"> publicvoidsetAllItemChecked(booleanbCheckStatus){<br style="line-height:25px"> intdataCount=mList.getCount();<br style="line-height:25px"> for(inti=0;i<dataCount;++i){<br style="line-height:25px"> //ListView.setItemChecked()???????ListView??????<br style="line-height:25px"> //requestLayout()???????????itemrow????<br style="line-height:25px"> //getView()?????????.<br style="line-height:25px"> mList.setItemChecked(i,bCheckStatus);<br style="line-height:25px"> }<br style="line-height:25px"> }<br style="line-height:25px"><br style="line-height:25px"> publicintgetAgendaTagVisibility(intagendaicontype)<br style="line-height:25px"> {<br style="line-height:25px"> intvisibility=View.VISIBLE;<br style="line-height:25px"><br style="line-height:25px"> switch(agendaicontype)<br style="line-height:25px"> {<br style="line-height:25px"> caseAGENDA_TAG_ICON_FACEBOOK:<br style="line-height:25px"> visibility=View.VISIBLE;<br style="line-height:25px"> break;<br style="line-height:25px"> caseAGENDA_TAG_ICON_GOOGLE:<br style="line-height:25px"> visibility=View.INVISIBLE;<br style="line-height:25px"> break;<br style="line-height:25px"> caseAGENDA_TAG_ICON_NONE:<br style="line-height:25px"> default:<br style="line-height:25px"> visibility=View.GONE;<br style="line-height:25px"> break;<br style="line-height:25px"> }<br style="line-height:25px"><br style="line-height:25px"> returnvisibility;<br style="line-height:25px"> }<br style="line-height:25px"><br style="line-height:25px"><span style="color:#808080; line-height:25px">/**<br style="line-height:25px"> *@authorcooldawn.kim<br style="line-height:25px"> *<br style="line-height:25px"> *AgendaItem<br style="line-height:25px"> */</span><br style="line-height:25px"><span style="color:#3366ff; line-height:25px"></span><span style="color:#993300; line-height:25px">class</span><span style="color:#3366ff; line-height:25px"></span><span style="color:#ff6600; line-height:25px">AgendaItem</span><span style="color:#3366ff; line-height:25px">{<br style="line-height:25px"> privateintmAgendarcolor;<br style="line-height:25px"> privateintmAgendatabicon;<br style="line-height:25px"> privateStringmAgenda;<br style="line-height:25px"> privateStringmTag;<br style="line-height:25px"><br style="line-height:25px"> publicAgendaItem(intcolor,inttagicon,Stringagenda,Stringtag)<br style="line-height:25px"> {<br style="line-height:25px"> this.mAgendarcolor=color;<br style="line-height:25px"> this.mAgendatabicon=tagicon;<br style="line-height:25px"> this.mAgenda=agenda;<br style="line-height:25px"> this.mTag=tag;<br style="line-height:25px"> }<br style="line-height:25px"><br style="line-height:25px"> publicintgetAgendaColorType(){<br style="line-height:25px"> returnmAgendarcolor;<br style="line-height:25px"> }<br style="line-height:25px"><br style="line-height:25px"> publicintgetAgendaTagIconType(){<br style="line-height:25px"> returnmAgendatabicon;<br style="line-height:25px"> }<br style="line-height:25px"><br style="line-height:25px"> publicStringgetAgendaText(){<br style="line-height:25px"> returnmAgenda;<br style="line-height:25px"> }<br style="line-height:25px"><br style="line-height:25px"> publicStringgetAgendaTag(){<br style="line-height:25px"> returnmTag;<br style="line-height:25px"> }<br style="line-height:25px"><br style="line-height:25px"> }//classAgendaItem</span><br style="line-height:25px"><br style="line-height:25px"><span style="color:#808080; line-height:25px">/**<br style="line-height:25px"> *[09.10.23]<br style="line-height:25px"> *@authorrhoon<br style="line-height:25px"> *<br style="line-height:25px"> *publicclass<br style="line-height:25px"> *Checkablelinearlayout.??Checkable?????????????<br style="line-height:25px"> *?????forwarding????????.<br style="line-height:25px"> */</span><br style="line-height:25px"><span style="color:#3366ff; line-height:25px"></span><span style="color:#993300; line-height:25px">publicstaticclass</span><span style="color:#3366ff; line-height:25px"></span><span style="color:#ff6600; line-height:25px">ItemView</span><span style="color:#3366ff; line-height:25px">extendsLinearLayoutimplementsCheckable{</span><br style="line-height:25px"><br style="line-height:25px"><span style="color:#3366ff; line-height:25px">publicItemView(Contextcontext,AttributeSetattrs){</span><br style="line-height:25px"><span style="color:#3366ff; line-height:25px">super(context,attrs);</span><br style="line-height:25px"><span style="color:#3366ff; line-height:25px">}</span><br style="line-height:25px"><br style="line-height:25px"><span style="color:#3366ff; line-height:25px">publicbooleanisChecked(){</span><br style="line-height:25px"><span style="color:#3366ff; line-height:25px">CheckBoxcheck=findCheckBox();</span><br style="line-height:25px"><span style="color:#3366ff; line-height:25px">if(check!=null){</span><br style="line-height:25px"><span style="color:#3366ff; line-height:25px">returncheck.isChecked();</span><br style="line-height:25px"><span style="color:#3366ff; line-height:25px">}</span><br style="line-height:25px"><span style="color:#3366ff; line-height:25px">returnfalse;</span><br style="line-height:25px"><span style="color:#3366ff; line-height:25px">}</span><br style="line-height:25px"><br style="line-height:25px"><span style="color:#3366ff; line-height:25px">publicvoidsetChecked(booleanchecked){</span><br style="line-height:25px"><span style="color:#3366ff; line-height:25px">Log.d("ItemView","setChecked("+checked+")");</span><br style="line-height:25px"><span style="color:#3366ff; line-height:25px">CheckBoxcheck=findCheckBox();</span><br style="line-height:25px"><span style="color:#3366ff; line-height:25px">if(check!=null){</span><br style="line-height:25px"><span style="color:#3366ff; line-height:25px">check.setChecked(checked);</span><br style="line-height:25px"><span style="color:#3366ff; line-height:25px">}</span><br style="line-height:25px"><span style="color:#3366ff; line-height:25px">}</span><br style="line-height:25px"><br style="line-height:25px"><span style="color:#3366ff; line-height:25px">publicvoidtoggle(){</span><br style="line-height:25px"><span style="color:#3366ff; line-height:25px">CheckBoxcheck=findCheckBox();</span><br style="line-height:25px"><span style="color:#3366ff; line-height:25px">if(check!=null){</span><br style="line-height:25px"><span style="color:#3366ff; line-height:25px">check.toggle();</span><br style="line-height:25px"><span style="color:#3366ff; line-height:25px">}</span><br style="line-height:25px"><span style="color:#3366ff; line-height:25px"></span><br style="line-height:25px"><span style="color:#3366ff; line-height:25px">}</span><br style="line-height:25px"><span style="color:#3366ff; line-height:25px"></span><br style="line-height:25px"><span style="color:#3366ff; line-height:25px">privateCheckBoxfindCheckBox(){</span><br style="line-height:25px"><span style="color:#3366ff; line-height:25px">Viewcheck=findViewById(R.id.checkbox1);</span><br style="line-height:25px"><span style="color:#3366ff; line-height:25px">if(check!=null&&checkinstanceofCheckBox){</span><br style="line-height:25px"><span style="color:#3366ff; line-height:25px">return(CheckBox)check;</span><br style="line-height:25px"><span style="color:#3366ff; line-height:25px">}</span><br style="line-height:25px"><span style="color:#3366ff; line-height:25px">returnnull;</span><br style="line-height:25px"><span style="color:#3366ff; line-height:25px">}</span><br style="line-height:25px"><span style="color:#3366ff; line-height:25px"></span><br style="line-height:25px"><span style="color:#3366ff; line-height:25px">}</span><br style="line-height:25px"> }</wbr></wbr></wbr></wbr>