android - Scrolling does not work on ScrollView -
i have scrollview follows:
<scrollview xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" > <relativelayout android:layout_height="wrap_content" android:layout_width="fill_parent" android:orientation="horizontal"> <textview android:id="@+id/filtersdialogpreference_textview" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparentleft="true" android:layout_centervertical="true" /> <checkbox android:id="@+id/filtersdialogpreference_checkbox" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparentright="true" android:layout_centervertical="true" /> </relativelayout>
corresponding class uses xml above
public class filtersdialogpreference extends dialogpreference implements onclicklistener{ public filtersdialogpreference(context context, attributeset attrs) { super(context, attrs); setpersistent(false); mcontext = context; } @override public void onbinddialogview(view view) { super.onbinddialogview(view); } @override protected view oncreatedialogview() { linearlayout layout = null; filters = new arraylist<filter>(); checkboxes = new arraylist<checkbox>(); layoutinflater minflater = (layoutinflater) getcontext().getsystemservice(context.layout_inflater_service); layout = (linearlayout) minflater.inflate(r.layout.filter_dialog_preference, null, false); filtersdatasource ds = new filtersdatasource(mcontext); ds.open(); // read current filter preferences arraylist<string> ids = ds.getfilterids(); view filterview; (int = 0; < ids.size(); i++) { string name = ds.getfilter(ids.get(i)).getfiltername(); boolean ismonitored = ds.ismonitored(ids.get(i)); filters.add(new filter(ids.get(i), name, ismonitored)); filterview = minflater.inflate(r.layout.filter_selection_item, null); textview nametv = (textview) filterview.findviewbyid(r.id.filtersdialogpreference_textview); nametv.settext(name); checkbox checkbox = (checkbox) filterview.findviewbyid(r.id.filtersdialogpreference_checkbox); checkbox.setonclicklistener(this); checkbox.setchecked(ismonitored); checkboxes.add(checkbox); layout.addview(filterview); } ds.close(); return layout; } @override public void ondialogclosed(boolean positiveresult) { if (positiveresult) { log.v(gsguiconst.log_dev, "saving filter settings"); filtersdatasource ds = new filtersdatasource(mcontext); ds.open(); (int = 0; < filters.size(); i++) { string _id = filters.get(i).mid; boolean enabled = filters.get(i).isenabled(); ds.setmonitoredvalue(_id, enabled); //log.v(gsguiconst.log_dev, "reread"+ds.getfilter(_id).getfiltername()+": "+ds.ismonitored(_id)); } ds.close(); } } private class filter { private string mname; private boolean menabled; private string mid; public filter(string _id, string name, boolean enabled) { mid = _id; mname = name; menabled = enabled; } public string getid() { return mid; } public boolean isenabled() { return menabled; } public void setenabled(boolean monitored) { menabled = monitored; } public string tostring() { return mname; } } @override public void onclick(view v) { checkbox checkbox = (checkbox)v; int id = checkboxes.indexof(checkbox); filters.get(id).setenabled(checkbox.ischecked()); }
}
there lots of entries on settings activity, unfortunatelly layout not react on scrolling. idea? not sure if scrollview necessary @ all. linearlayout should handle scrolling well, shouldn't it?
set in xml
android:maxlines = "100" android:scrollbars = "vertical"
then use in activity oncreate:
textview yourtextview = (textview) findviewbyid (r.id.textview1) yourtextview.setmovementmethod(new scrollingmovementmethod())
Comments
Post a Comment