my list view has some toggle button and dates which is to be checked and uncheck on the basis of user choice
the functionality is to set alarm for those days when button is checked
when i am clicking the toggle button it sets the alarm for the day
but when i click next button it overwrite it
**for ex ... let the user has choice to set alarm for 1, 2 3, 4 or all dates and individual toggle button for this if the user has selected 1, 4,5 then it will work for 5 not for all
one more issue which i am unable to figure out is when i scroll the list view and the checked button get disappear it automatically sets it unchecked**
pour une raison quelconque, je ne peux pas mettre le codebouton à bascule ne reste pas dans son état
DDListAdapter public class étend BaseAdapter {
ArrayList<DataModelDD> listArray; int curIndex=1000, pIndex; public DDListAdapter(String[] str, String[] str1) { listArray = new ArrayList<DataModelDD>(); for (int i=0; i < str.length; i++) { listArray.add(new DataModelDD(str[i],str1[i], "Dry Day Alert on " + str[i])); } } public void DDListUpdate(String[] str, String[] str1){ listArray = new ArrayList<DataModelDD>(); for (int i=0; i < str.length; i++) { listArray.add(new DataModelDD(str[i],str1[i], "Dry Day Alert on " + str[i])); } this.notifyDataSetChanged(); } @Override public int getCount() { return listArray.size(); // total number of elements in the list } @Override public Object getItem(int i) { return listArray.get(i); // single item in the list } @Override public long getItemId(int i) { return i; // index number } @Override public View getView(final int index, View view, final ViewGroup parent) { pIndex = index; LayoutInflater inflater = LayoutInflater.from(parent.getContext()); view = inflater.inflate(R.layout.lstdd, parent, false); final DataModelDD dmFl = listArray.get(index); final TextView lbl1 = (TextView) view.findViewById(R.id.txtDDate); final TextView lbl2 = (TextView) view.findViewById(R.id.txtDres); lbl1.setText(dmFl.getDDate()); lbl2.setText(dmFl.getDres()); final ToggleButton btnDShare = (ToggleButton) view.findViewById(R.id.btnDShare); final ToggleButton btnlock = (ToggleButton) view.findViewById(R.id.btnDAlarm); btnDShare.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if(btnDShare.isChecked()){ // TODO Auto-generated method stub Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND); sharingIntent.setType("text/plain"); String shareBody = "Dry Day Alert on " + lstMonth.getSelectedItem().toString() + dmFl.getDDate() + " for " + dmFl.getDres(); sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "DryDayApp"); sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareBody); parent.getContext().startActivity(Intent.createChooser(sharingIntent, "Share via")); } } }); btnlock.setOnCheckedChangeListener(new OnCheckedChangeListener(){ @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if(btnlock.isChecked()){ final String alarmTime = dmFl.getDDate(); final String reason = dmFl.getDres(); enableAlarm(buttonView,alarmTime,reason); buttonView.setChecked(true); astatus = true; } else{ final String alarmTime = dmFl.getDDate(); disableAlarm(buttonView,alarmTime); buttonView.setChecked(false); astatus = false; } } }); return view; } }
qu'est-ce que buttonView et où vous l'avez déclaré? –