我知道如何将ToggleButton添加到所有listView行。但是,如何将ToggleButton添加到一个特定的listView行?
我用listAdapter填充我的listView,如此
ListView mlistView = (ListView) findViewById(R.id.listViewSetting);
mlistView.setAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1,
new String[] {"Rate @ME App", "Feedback", "Block", "Terms of Service", "Push Notifications", "Sign Out"}));
答案 0 :(得分:2)
这是一些伪代码
@Override
public View getView(final int position, final View convertView, final ViewGroup parent) {
// Do inflation here, use a viewholder pattern to improve performance
// Add logic to handle togglebutton, view being togglebutton
if(items.get(position).equals(something){
view.setVisibilty(View.Visible);
}else{
view.setVisibilty(View.GONE);
}
}