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;
}
}*/
}
radiobtn的listview,自定义arrayAdapter构成样式
最新推荐文章于 2024-05-30 10:44:35 发布