1

ListActivityを拡張するクラスでは、作成している各アイテムが複数のアイテムとして表示されます。UIの下部に「1つだけ」のボタンを配置したいのですが...問題は、そのボタンを作成すると、ボタンのリストとして表示されますが、必要なボタンは1つだけです。 ...誰か助けてもらえますか?これが私のコードです、

public class ListViewActivity extends ListActivity implements OnCheckedChangeListener {

TextView label;
CheckBox checkBox;
private ArrayList<Boolean> status = new ArrayList<Boolean>();

public class MyCustomAdapter extends ArrayAdapter<String> {


public MyCustomAdapter(Context context, int textViewResourceId,
  String[] objects) {

    super(context, textViewResourceId, objects);

    for (int i = 0; i < objects.length; i++) {
        status.add(false);
    }
  // TODO Auto-generated constructor stub
 }

@Override
public View getView(final int position, View convertView, ViewGroup parent) {
 // TODO Auto-generated method stub
 //return super.getView(position, convertView, parent);

 View row = convertView;

 if(row==null){
  LayoutInflater inflater=getLayoutInflater();
  row=inflater.inflate(R.layout.main, parent, false); 

 }  


 label=(TextView)row.findViewById(R.id.months);
 label.setText(month[position]);



 checkBox=(CheckBox)row.findViewById(R.id.checkBox);
 checkBox.setFocusable(false);
 checkBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {

 @Override
 public void onCheckedChanged(CompoundButton buttonView,boolean isChecked) {

         String event = null;

         if (isChecked) 
         {
         status.set(position, true);
         event = " just checked!";
         } 

        else 
         {
         status.set(position, false);
         event = " just unchecked!";
         }

         Toast.makeText(getApplicationContext(), "checkbox " + position +event,    Toast.LENGTH_SHORT).show();   

 }
 });
 checkBox.setChecked(status.get(position));



 return row;
}
}

String[] month = {
    "January", "February", "March", "April",
    "May", "June", "July", "August",
    "September", "October", "November", "December"
  };

 /** Called when the activity is first created. */
 @Override
 public void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);
 // setContentView(R.layout.main);
 /*setListAdapter(new ArrayAdapter<String>(this,
   R.layout.row, R.id.weekofday, DayOfWeek));*/


   setListAdapter(new MyCustomAdapter(ListViewActivity.this, R.layout.main, month));


   //here are the button I am talking about     
   Button saveButton = (Button) this.findViewById(R.id.button1);




  }


  }
4

1 に答える 1