0

I have a custom list view populated with radio button and text views. I have implemented onListItemClick listener for listview. My problem is i want to check the radio button on clicking an row in list view , but all rows radio button state changes to true. I am unable to figure out reason onListItem Listener snippets

                listView.setOnItemClickListener(new OnItemClickListener() 
            {
                @Override
                public void onItemClick(AdapterView<?> arg0, View rowView,
                        int pos, long id) 
                {
                    rbChgPlan = (RadioButton) rowView.findViewById(R.id.radioButton);
                    rbChgPlan.setChecked(true);
                    planId= newPlans.get(pos).plan_id;

                    adapter.notifyDataSetChanged();
                }
            });

pls providesuggestions

4

1 回答 1

0

尝试覆盖适配器的 getview 方法。

public View getView(final int position, View convertView, final ViewGroup parent) {
    View v = convertView;
    if (v == null) {
        LayoutInflater vi = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        v = vi.inflate(R.layout.masterlist, null);
    }
    rbChgPlan  = (RadioButton) v.findViewById(R.id.ckbox1);
    rbChgPlan.setChecked(true);
});
return v;
}
于 2013-04-06T07:14:37.517 回答