radiobtn的listview,自定义arrayAdapter构成样式

public class myActivity extends ListActivity { private BroadcastReceiver mSDCardCheckReceiver = null; boolean m0Min = false; boolean m1Min = false; boolean m2Min = false; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //registerStatusReceiver(); //registerExternalStorageListener(); setContentView(R.layout.recording_time); } protected void onResume() { super.onResume(); listBinding(); } public void onDestroy() { super.onDestroy(); //unRegisterStatusReceiver(); //unRegisterExternalStorageListener(); } public void listBinding() { ArrayList<CheckListItem> i = new ArrayList<CheckListItem>(); int cur = VRSettings.getVRSettings(this).getSavingTime(); m0Min = false; m1Min = false; m2Min = false; if(cur == 0 ) m0Min = true; else if(cur == 1) m1Min = true; else if(cur == 2) m2Min = true; i.add(new CheckListItem("time0", m0Min); i.add(new CheckListItem("time1", m1Min)); i.add(new CheckListItem("time2", m2Min)); CheckListAdapter adapter = new CheckListAdapter(this, R.layout.vr_list_row_radiobtn, i); setListAdapter(adapter); adapter.notifyDataSetChanged(); } public void onListItemClick(ListView listview, View view, int position, long id) { //dosomething VRSettings.getVRSettings(this).setSavingTime(position); finish(); } private class CheckListAdapter extends ArrayAdapter<CheckListItem> { public CheckListAdapter(Context context, int textViewResourceId, ArrayList<CheckListItem> items) { super(context, 0, items); } public View getView(int position, View convertView, ViewGroup parent) { View v = convertView; if (v == null) { LayoutInflater vi = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = vi.inflate(R.layout.vr_list_row_radiobtn, null); } CheckListItem item = getItem(position); TextView t = (TextView)v.findViewById(R.id.item); t.setText(item.getText()); TwRadioButton i = (TwRadioButton)v.findViewById(R.id.radiobtn); if (item.getCheckBox()) { i.setChecked(true); } else { i.setChecked(false); } return v; } } class CheckListItem { private String text; private boolean check; public CheckListItem(String _text, boolean _check) { text = _text; check = _check; } public String getText() { return text; } public boolean getCheckBox() { return check; } } /*private void registerExternalStorageListener() { IntentFilter iFilter = new IntentFilter(); iFilter.addAction(Intent.ACTION_MEDIA_UNMOUNTED); iFilter.addAction(Intent.ACTION_MEDIA_MOUNTED); iFilter.addDataScheme("file"); mSDCardCheckReceiver = new BroadcastReceiver() { public void onReceive(Context context, Intent intent) { if(intent.getAction().equals(Intent.ACTION_MEDIA_UNMOUNTED)){ Log.v(TAG,"mSDCardMountEventReceiver. ACTION_MEDIA_UNMOUNTED"); Toast.makeText(ActivityNoFile.this, R.string.media_scanning, Toast.LENGTH_SHORT).show(); destroy(); return; } else if( intent.getAction().equals(Intent.ACTION_MEDIA_MOUNTED)){ Log.v(TAG,"mSDCardMountEventReceiver. ACTION_MEDIA_MOUNTED"); mtoast.cancel(); mtoast.show(); destroy(); return; } } }; registerReceiver(mSDCardCheckReceiver, iFilter); } private void unRegisterExternalStorageListener() { if( mSDCardCheckReceiver != null){ unregisterReceiver(mSDCardCheckReceiver); mSDCardCheckReceiver = null; } }*/ }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值