遍歷ListView,查出每一項的內容


private ListView.OnItemClickListener showItemDetail = new ListView.OnItemClickListener()
{
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
{
//全選遍歷ListView的選項,設置所有的layDetail不可見
for(int i = 0; i < lvList.getChildCount(); i++)
{
View viewChild = lvList.getChildAt(i);
LinearLayout layMain = (LinearLayout)viewChild.findViewById(R.id.layMain);
LinearLayout layDetail = (LinearLayout)viewChild.findViewById(R.id.layDetail);
layMain.setBackgroundDrawable(getResources().getDrawable(R.drawable.mm_listitem));
layDetail.setVisibility(View.GONE);
}

LinearLayout layMain = (LinearLayout)view.findViewById(R.id.layMain);
LinearLayout layDetail = (LinearLayout)view.findViewById(R.id.layDetail);

if (layDetail.getVisibility() == View.VISIBLE)
{
layDetail.setVisibility(View.GONE);
layMain.setBackgroundDrawable(getResources().getDrawable(R.drawable.mm_listitem));
}
else
{
layDetail.setVisibility(View.VISIBLE);
layMain.setBackgroundDrawable(getResources().getDrawable(R.drawable.mm_listitem_pressed));
}
}
};


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM