android - To set the clickable list -
i have written code set list,now want clickable list how it.when clicking on perticular item should clickable.whan clicking on trxtview action should happen , when clicking on button action should happen.
my code is
public class downloadlist extends listactivity { private list<string> item = null; private list<string> path = null; private string root="/sdcard"; private textview mypath; listview lv1; public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.mydownload); mypath = (textview)findviewbyid(r.id.path); lv1=(listview)findviewbyid(r.id.list); getdir(root); } private void getdir(string dirpath) { mypath.settext("location: " + dirpath); item = new arraylist<string>(); path = new arraylist<string>(); file f = new file(dirpath); file[] files = f.listfiles(); if(!dirpath.equals(root)) { item.add(root); path.add(root); item.add("../"); path.add(f.getparent()); } for(int i=0; < files.length; i++) { file file = files[i]; path.add(file.getpath()); if(file.isdirectory()) item.add(file.getname() + "/"); else item.add(file.getname()); } log.d("itemssssssss", item.tostring()); arrayadapter<string> filelist = new arrayadapter<string>(this, r.layout.rowmydownload,r.id.rowtext, this.item); setlistadapter(filelist); } }
having button in listview item make view unclickable. use imageview instead of button , put onitemclicklistener listview in activity. in adapter, put onclicklistener textview , imageview.
Comments
Post a Comment